Uh oh!
There was an error while loading. Please reload this page.
[stubtest] Verify __all__ exists in stub - #18005
Conversation
JelleZijlstra
commented
Oct 21, 2024
Does this cause a lot of new errors in typeshed? |
srittau
commented
Oct 21, 2024
How can we check that? If it does, I suggest we just mass add |
JelleZijlstra
commented
Oct 21, 2024
I tried locally (by installing this PR branch and running typeshed tests), and didn't see any new errors—which actually seems a little suspicious. |
srittau
commented
Oct 21, 2024
Very. I suspect there to be a quite significant number of hits. |
JelleZijlstra
commented
Oct 21, 2024
It was because of #18007; I forgot that stubtest doesn't do anything if there are mypy errors in the stubs. With this patch: Detailsdiff --git a/pyproject.toml b/pyproject.toml
index 46014bcd2..77e5e3127 100644
--- a/pyproject.toml+++ b/pyproject.toml@@ -166,3 +166,6 @@ known-first-party = ["ts_utils", "_utils"]
[tool.typeshed]
oldest_supported_python = "3.8"
++[tool.mypy]+disable_error_code = "deprecated"diff --git a/tests/stubtest_stdlib.py b/tests/stubtest_stdlib.py
index 5134f8270..77dab3d20 100755
--- a/tests/stubtest_stdlib.py+++ b/tests/stubtest_stdlib.py@@ -29,6 +29,8 @@ def run_stubtest(typeshed_dir: Path) -> int:
"--check-typeshed",
"--custom-typeshed-dir",
str(typeshed_dir),
+ "--mypy-config-file",+ str(typeshed_dir / "pyproject.toml"),
*allowlist_stubtest_arguments("stdlib"),
]
if sys.version_info < (3, 10):I get these in the stdlib on macOS and 3.12: Didn't run it on all the third-party stubs. |
Interesting. I just commented out |
JelleZijlstra
commented
Oct 21, 2024
Did you use |
srittau
commented
Oct 21, 2024
Yes, it seems that way. I added debug statements to the installed mypy and those are not printed either. |
JelleZijlstra
commented
Oct 21, 2024
Yes, if you want to test you'll have to edit requirements.txt or otherwise hack the script. I think the stdlib results are enough for me to believe that this works as expected, so I'm happy to merge this, but I'll wait a little bit in case Shantanu/Alex/someone else seeing this has more feedback. |
I do have a question: Do we want to report cases where |
srittau
commented
Oct 21, 2024
I would say yes. Stubs beings closer to the implementation has value in itself, instead of special casing specific cases. Also, it means that |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
1.14 introduced [a change](python/mypy#18005) that our `__init__.py` doesn't, and can't comply with. Our `__init__.py` looks like this: ```py _exported_symbols.extend([ "Value", "NullValue", "BooleanValue", "UnsignedBinaryValue", "UnsignedShortValue", "UnsignedIntegerValue", "UnsignedLongValue", "BinaryValue", "ShortValue", "IntegerValue", "LongValue", "HugeIntegerValue", "FloatValue", "DoubleValue", "DecimalValue", "StringValue", "UUIDValue", "BitValue", "BlobValue", "DateValue", "IntervalValue", "TimestampValue", "TimestampSecondValue", "TimestampMilisecondValue", "TimestampNanosecondValue", "TimestampTimeZoneValue", "TimeValue", "TimeTimeZoneValue", ]) __all__ = _exported_symbols ``` Which I'm pretty sure is non-standard, and creates a warning, but this works for us Mypy is not happy about this because it seems `__all__` is expected to be a constant expression, and expected to be copied to the `__init__.pyi` file
Previously it wasn't an error if runtime included an
__all__declaration, but the stubs did not. This PRchanges this to reflect the consensus that it would
be a good idea to ensure consistency in this case.
Fixes#13300