You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> mypy --python-version 3.10 test.py
test.py:5: note: Revealed type is "enum.Enum"
test.py:6: note: Revealed type is "str"
Success: no issues found in 1 source file
> mypy --python-version 3.11 test.py
test.py:5: note: Revealed type is "enum.Enum"
test.py:6: note: Revealed type is "Any"
Not 100% sure if this is a mypy issue or a typeshed issue,
It's an alias for property in the stubs. So on 3.11 we are using a subclass of property (from mypy's perspective), but on 3.10 and lower we are just using an alias. I guess the subclass is what's causing trouble.
For Enum.name specifically, we can probably just pretend that it still uses types.DynamicClassAttribute in 3.11, as it does in <=3.10. It doesn't make much difference in the stubs, especially when mypy doesn't really support the intricacies of either types.DynamicClassAttribute or enum.property.
Activity
JelleZijlstra commentedon Mar 29, 2022
I guess mypy doesn't understand the
_magic_enum_attrhere: https://github.com/python/typeshed/blob/master/stdlib/enum.pyi#L144KotlinIsland commentedon Mar 29, 2022
Is that intrinsic and needs to be special cased, or should it be handled by default?
JelleZijlstra commentedon Mar 29, 2022
It's an alias for
propertyin the stubs. So on 3.11 we are using a subclass of property (from mypy's perspective), but on 3.10 and lower we are just using an alias. I guess the subclass is what's causing trouble.KotlinIsland commentedon Mar 29, 2022
Thanks, I'll raise it with mypy, should we close this?
JelleZijlstra commentedon Mar 29, 2022
It does on main, maybe you have an old 3.11 checkout.
https://github.com/python/cpython/blob/788154919c2d843a0a995994bf2aed2d074761ec/Lib/enum.py#L150
KotlinIsland commentedon Mar 29, 2022
I had my 3.10 venv active 😳
AlexWaygood commentedon Mar 29, 2022
For
Enum.namespecifically, we can probably just pretend that it still usestypes.DynamicClassAttributein 3.11, as it does in <=3.10. It doesn't make much difference in the stubs, especially when mypy doesn't really support the intricacies of eithertypes.DynamicClassAttributeorenum.property.Sound good?
target python 3.10 as the mypy language version
target python 3.10 as the mypy language version
target python 3.10 as the mypy language version
Correctly handle Enum name on Python 3.11 (python#14133)