-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Annotating Enum
attributes with Final
causes surprising type violations
#8543
Comments
…ute. This should be considered invalid. This addresses #8543.
Here's the applicable wording from the typing spec:
Based on that wording, an annotation of In any case, you shouldn't use I'll update pyright to emit an error for a |
This is addressed in pyright 1.1.374. |
When
Enum
attributes are annoted withtyping.Final
, the "Type annotations are not allowed for enum members" warning is not raised as it would be for similar invalid annotations. Such attributes also also treated as having the annotated type instead of itsEnum
derived type.For the code below:
pyright
, instrict
mode, will raise the following:To summarize:
FINAL
attribute should also be flagged byreportGeneralTypeIssues
?BadEnum.STR
andBadEnum.FINAL
should still be treated asBadEnum
instead ofstr
andLiteral['final']
Issue noticed after updating
opentelemetry-semantic-convention
to a version that contains open-telemetry/opentelemetry-python#3966The text was updated successfully, but these errors were encountered: