-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Sync typeshed #14815
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
Sync typeshed #14815
Conversation
This comment has been minimized.
This comment has been minimized.
Most of the hits here are from python/typeshed#6670. That typeshed commit solves a lot of issues for pyright, but it seems like it currently only causes false positives for mypy. Until mypy improves its support for |
Yeah, I'd be in favour of reverting it as well. |
This comment has been minimized.
This comment has been minimized.
|
4 of the errors from the typeshed
Looking at the implementation of |
Want to try making a typeshed PR? |
Sure. |
You can obviously cook up theoretical situations where adding >>> class Foo:
... def __call__(self): ...
...
>>> class Bar:
... def __call__(self): ...
...
>>> from functools import update_wrapper
>>> wrapped = Foo()
>>> wrapper = Bar()
>>> update_wrapper(wrapper, wrapped)
<__main__.Bar object at 0x000002CB493C9C50>
>>> _.__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Bar' object has no attribute '__name__'. Did you mean: '__ne__'? But these seem pretty rare, and not worth worrying about. Adding |
FWIW though, even if we make that change, I think I'd still want the changes to |
Thanks, this looks good but we should probably resync with python/typeshed#9835 since that'll be another merge conflict |
python/typeshed#9815 will also cause merge conflicts for the next sync — any interest in taking a quick look at that one before I resync? |
Source commit: python/typeshed@257e287
This is allegedly causing large performance problems, see 13821 typeshed/8231 had zero hits on mypy_primer, so it's not the worst thing to undo. Patching this in typeshed also feels weird, since there's a more general soundness issue. If a typevar has a bound or constraint, we might not want to solve it to a Literal. If we can confirm the performance regression or fix the unsoundness within mypy, I might pursue upstreaming this in typeshed. (Reminder: add this to the sync_typeshed script once merged)
Since the plugin provides superior type checking: python#13987 (comment)
ef82701
to
cc24483
Compare
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip)
+ src/pip/_internal/locations/_distutils.py:60: error: Unused "type: ignore" comment
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/structured_configs/_utils.py:69: error: Name "get_origin" already defined (possibly by an import) [no-redef]
- src/hydra_zen/structured_configs/_utils.py:69: error: All conditional function variants must have identical signatures [misc]
- src/hydra_zen/structured_configs/_utils.py:69: note: Original:
- src/hydra_zen/structured_configs/_utils.py:69: note: def get_origin(tp: Any) -> Optional[Any]
- src/hydra_zen/structured_configs/_utils.py:69: note: Redefinition:
- src/hydra_zen/structured_configs/_utils.py:69: note: def get_origin(tp: Any) -> Optional[type]
pydantic (https://github.com/samuelcolvin/pydantic)
+ pydantic/_internal/_generate_schema.py:377: error: Unused "type: ignore" comment
|
Thanks! |
Source commit: python/typeshed@257e287.
The automated PR by the bot failed again due to merge conflicts with the cherry-picked commits: https://github.com/python/mypy/actions/runs/4298562919/jobs/7492803753#step:5:53.