-
-
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
Enum field 'name' conflics with instance attribute 'name' #4654
Comments
Hm, is the stub file a |
This is a stub, the problem is the stub for Enum says 'name: str' so we are conflicting with that |
It is, in fact not a bug in typeshed. |
I guess i'm not sure what the fix is, Enum instances do have a .name and .value. |
I think this does deserve some discussion, and I think considering the trickery of Enum, we might need to modify the stubs and mypy to handle Enum attributes differently from Enum inheriting types themselves. Let me think about this some more. |
Yeah, this is tricky. We may have to special-case this in mypy. However maybe @elazarg has an idea, he seems to understand the Enum stuff best. |
Shouldn't the enum attributes be considered implicitly |
We looked at this and there's another related issue here. mypy's special handling of Enum already treats
Mypy correctly finds that
This is not a typeshed problem since the revealed type goes against what typeshed defines for
|
I suspect this code is a little lax: https://github.com/python/mypy/blob/master/mypy/checkmember.py#L440 |
This is my stub file which I can control.
error: Incompatible types in assignment (expression has type "ellipsis", base class "Enum" defined the type as "str")
The enum is defined as
This is autogenerated code and I don't have control over the enum field names, is there some way for me to have a working stub for this code?
The text was updated successfully, but these errors were encountered: