-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[stubtest] Verify __all__ exists in stub #18005
Conversation
Does this cause a lot of new errors in typeshed? |
How can we check that? If it does, I suggest we just mass add |
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. |
Very. I suspect there to be a quite significant number of hits. |
It was because of #18007; I forgot that stubtest doesn't do anything if there are mypy errors in the stubs. With this patch: diff --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 |
Did you use |
Yes, it seems that way. I added debug statements to the installed mypy and those are not printed either. |
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 |
I would say yes. Stubs beings closer to the implementation has value in itself, instead of special casing specific cases. Also, it means that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
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