mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.11] gh-111181: Fix enum doctests (GH-111180) (GH-111617)
gh-111181: Fix enum doctests (GH-111180)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
(cherry picked from commit c4dc5a6ae8
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
a106f61b72
commit
4a61169672
3 changed files with 21 additions and 15 deletions
11
Lib/enum.py
11
Lib/enum.py
|
@ -1197,14 +1197,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():
|
||||
|
@ -1217,7 +1216,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__'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue