-
-
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
Marks enums with values as implicitly final #11247
Conversation
@@ -1096,8 +1096,8 @@ def analyze_class(self, defn: ClassDef) -> None: | |||
self.update_metaclass(defn) | |||
|
|||
bases = defn.base_type_exprs | |||
bases, tvar_defs, is_protocol = self.clean_up_bases_and_infer_type_variables(defn, bases, | |||
context=defn) | |||
bases, tvar_defs, is_protocol = self.clean_up_bases_and_infer_type_variables( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This: #11247 (comment) looks like a false positive. Will investigate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I like the detailed tests. Looks good, I only have one question.
and base.type.fullname not in ( | ||
'enum.Enum', 'enum.IntEnum', 'enum.Flag', 'enum.IntFlag') | ||
and base.type.names | ||
and any(not isinstance(n.node, (FuncBase, Decorator)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a nested class definition? Would it be fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also there's a merge conflict now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Rebased.
and base.type.fullname not in ( | ||
'enum.Enum', 'enum.IntEnum', 'enum.Flag', 'enum.IntFlag') | ||
and base.type.names | ||
and any(not isinstance(n.node, (FuncBase, Decorator)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now enums with values cannot be inherited:
In runtime it caused this error:
Now runtime and
mypy
are in sync.Closes #10857
Part of my "better enum" PR series: #10852