-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
1.5.0 regression: register
enum member typed as callable
#15870
Comments
Fixed in python/typeshed#10577. @svalentin FYI — this is another small typeshed tweak that fixes a regression in mypy 1.5.0 — it could possibly be worth cherry-picking to a 1.5 patch release if the PyPI overlords ever let us make another mypy release :-) Having said that, idk how many people are defining enums with a |
We should be starting 1.6 really soon since 1.5 was delayed quite a bit and there's already quite a number of changes to pick up. So it's probably best to just wait for 1.6. |
Thanks for the quick fix!
Agreed, especially given that it's recommended to use |
Does anybody here know how Mypy resolves the metaclass conflict (in typeshed) for
So AFAIK there's this conflict, which normally would raise |
Bug Report
When an enum has a
register
member, with mypy 1.5.0, mypy falsely considers it being of typeCallable[[Type[_T]], Type[_T]]
rather than the enum type.Bisected to 21cc1c7:
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=6115e84d079dcb7d03fe44174ddf5fb1
Actual Behavior
I believe this happens somehow because in
typeshed
(and only there),EnumMeta
inheritsABCMeta
:https://github.com/python/typeshed/blob/d82a8325faf35aa0c9d03d9e9d4a39b7fcb78f8e/stdlib/enum.pyi#L79-L84
and
ABCMeta
has aregister
method:https://docs.python.org/3/library/abc.html#abc.ABCMeta.register
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: