After merging #18559 I think it would make sense to change how we check for @final enums here:
|
def is_final_enum_value(self, sym: SymbolTableNode) -> bool: |
|
if isinstance(sym.node, (FuncBase, Decorator)): |
|
return False # A method is fine |
|
if not isinstance(sym.node, Var): |
|
return True # Can be a class or anything else |
|
|
|
# Now, only `Var` is left, we need to check: |
|
# 1. Private name like in `__prop = 1` |
|
# 2. Dunder name like `__hash__ = some_hasher` |
|
# 3. Sunder name like `_order_ = 'a, b, c'` |
|
# 4. If it is a method / descriptor like in `method = classmethod(func)` |
|
if ( |
|
is_private(sym.node.name) |
|
or is_dunder(sym.node.name) |
|
or is_sunder(sym.node.name) |
|
# TODO: make sure that `x = @class/staticmethod(func)` |
|
# and `x = property(prop)` both work correctly. |
|
# Now they are incorrectly counted as enum members. |
|
or isinstance(get_proper_type(sym.node.type), FunctionLike) |
|
): |
|
return False |
|
|
|
return self.is_stub or sym.node.has_explicit_value |
There's no need to duplicate the .enum_member logic here once again. I will refactor this piece.
After merging #18559 I think it would make sense to change how we check for
@finalenums here:mypy/mypy/checker.py
Lines 2705 to 2727 in d4e7a81
There's no need to duplicate the
.enum_memberlogic here once again. I will refactor this piece.