-
-
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
Enum
types cannot be inherited
#10857
Labels
Comments
I would love to work on it after #10852 |
hauntsaninja
pushed a commit
that referenced
this issue
Oct 31, 2021
achimnol
added a commit
to lablup/backend.ai-common
that referenced
this issue
Dec 27, 2021
@sobolevn, there appears to be a bug in the implementation of this feature. Mypy complains that class LabeledEnum(enum.Enum):
__labels__: Dict[str, str]
class Foo(LabeledEnum):
A = 1
B = 2
__labels__ = {
"A": "first enum",
"B": "second enum",
} I'm guessing mypy is unaware that members prefixed with |
I see that this bug has been raised in #11850. |
tushar-deepsource
pushed a commit
to DeepSourceCorp/mypy
that referenced
this issue
Jan 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature
Subtyping with
Enum
exact valuesThis core currently passes
mypy
:But, in runtime this code fails with:
This is also the case for
Flag
,IntEnum
, andIntFlag
.Subtyping without exact values
However, subtyping without
Enum
values is fine:This is also the case for
Flag
,IntEnum
, andIntFlag
.So, the rule is: types inherited from
Enum
with at least one enumeration value should be marked as implicitlyfinal
type.Related #10852
Related #5599
The text was updated successfully, but these errors were encountered: