Skip to content

Commit

Permalink
Cope with removal of EnumType.__getattr__ in 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Aug 5, 2023
1 parent 64cc5c2 commit e6adaef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
21 changes: 10 additions & 11 deletions pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,18 +478,17 @@ def _emit_no_member(
):
return False
if isinstance(owner, (astroid.Instance, nodes.ClassDef)):
# Issue #2565: Don't ignore enums, as they have a `__getattr__` but it's not
# invoked at this point.
try:
metaclass = owner.metaclass()
except astroid.MroError:
pass
else:
# Renamed in Python 3.10 to `EnumType`
if metaclass and metaclass.qname() in {"enum.EnumMeta", "enum.EnumType"}:
return not _enum_has_attribute(owner, node)
if owner.has_dynamic_getattr():
# Issue #2565: Don't ignore enums, as they have a `__getattr__` but it's not
# invoked at this point.
try:
metaclass = owner.metaclass()
except astroid.MroError:
return False
if metaclass:
# Renamed in Python 3.10 to `EnumType`
if metaclass.qname() in {"enum.EnumMeta", "enum.EnumType"}:
return not _enum_has_attribute(owner, node)
return False
return False
if not has_known_bases(owner):
return False
Expand Down
3 changes: 0 additions & 3 deletions tests/functional/e/enum_self_defined_member_5138.rc

This file was deleted.

0 comments on commit e6adaef

Please sign in to comment.