diff options
| author | Nikita Sobolev <mail@sobolevn.me> | 2023-10-30 19:56:29 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-30 19:56:29 (GMT) |
| commit | c4dc5a6ae8aa13abb743182df088f1a3526d1bcd (patch) | |
| tree | 8f4ac272a831679e9d3417ee2223d13be25568df /Lib/enum.py | |
| parent | cd6e0a04a16535d8bc727c84f73730c53267184e (diff) | |
| download | cpython-c4dc5a6ae8aa13abb743182df088f1a3526d1bcd.zip cpython-c4dc5a6ae8aa13abb743182df088f1a3526d1bcd.tar.gz cpython-c4dc5a6ae8aa13abb743182df088f1a3526d1bcd.tar.bz2 | |
gh-111181: Fix enum doctests (GH-111180)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Diffstat (limited to 'Lib/enum.py')
| -rw-r--r-- | Lib/enum.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/enum.py b/Lib/enum.py index 7d6e51d..4e76e96 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -1189,14 +1189,13 @@ class Enum(metaclass=EnumType): def __dir__(self): """ - Returns all members and all public methods + Returns public methods and other interesting attributes. """ - if self.__class__._member_type_ is object: - interesting = set(['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'value']) - else: + interesting = set() + if self.__class__._member_type_ is not object: interesting = set(object.__dir__(self)) for name in getattr(self, '__dict__', []): - if name[0] != '_': + if name[0] != '_' and name not in self._member_map_: interesting.add(name) for cls in self.__class__.mro(): for name, obj in cls.__dict__.items(): @@ -1209,7 +1208,7 @@ class Enum(metaclass=EnumType): else: # in case it was added by `dir(self)` interesting.discard(name) - else: + elif name not in self._member_map_: interesting.add(name) names = sorted( set(['__class__', '__doc__', '__eq__', '__hash__', '__module__']) |
