diff options
author | Sam Ezeh <sam.z.ezeh@gmail.com> | 2022-06-23 20:35:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-23 20:35:37 (GMT) |
commit | 28a2ccfff279867b87aa31f56bfc97cf3d6b3afe (patch) | |
tree | 2602f193ca101f3b8eac189fd3c82c71fd5d0da3 /Lib/enum.py | |
parent | 9a95fa9267590c6cc66f215cd9808905fda1ee25 (diff) | |
download | cpython-28a2ccfff279867b87aa31f56bfc97cf3d6b3afe.zip cpython-28a2ccfff279867b87aa31f56bfc97cf3d6b3afe.tar.gz cpython-28a2ccfff279867b87aa31f56bfc97cf3d6b3afe.tar.bz2 |
[Enum] Remove automatic docstring generation (GH-94188)
Diffstat (limited to 'Lib/enum.py')
-rw-r--r-- | Lib/enum.py | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/Lib/enum.py b/Lib/enum.py index a41422c..15c8d88 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -536,111 +536,6 @@ class EnumType(type): # update classdict with any changes made by __init_subclass__ classdict.update(enum_class.__dict__) # - # create a default docstring if one has not been provided - if enum_class.__doc__ is None: - if not member_names or not list(enum_class): - enum_class.__doc__ = classdict['__doc__'] = _dedent("""\ - Create a collection of name/value pairs. - - Example enumeration: - - >>> class Color(Enum): - ... RED = 1 - ... BLUE = 2 - ... GREEN = 3 - - Access them by: - - - attribute access:: - - >>> Color.RED - <Color.RED: 1> - - - value lookup: - - >>> Color(1) - <Color.RED: 1> - - - name lookup: - - >>> Color['RED'] - <Color.RED: 1> - - Enumerations can be iterated over, and know how many members they have: - - >>> len(Color) - 3 - - >>> list(Color) - [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>] - - Methods can be added to enumerations, and members can have their own - attributes -- see the documentation for details. - """) - else: - member = list(enum_class)[0] - enum_length = len(enum_class) - cls_name = enum_class.__name__ - if enum_length == 1: - list_line = 'list(%s)' % cls_name - list_repr = '[<%s.%s: %r>]' % (cls_name, member.name, member.value) - elif enum_length == 2: - member2 = list(enum_class)[1] - list_line = 'list(%s)' % cls_name - list_repr = '[<%s.%s: %r>, <%s.%s: %r>]' % ( - cls_name, member.name, member.value, - cls_name, member2.name, member2.value, - ) - else: - member2 = list(enum_class)[1] - member3 = list(enum_class)[2] - list_line = 'list(%s)%s' % (cls_name, ('','[:3]')[enum_length > 3]) - list_repr = '[<%s.%s: %r>, <%s.%s: %r>, <%s.%s: %r>]' % ( - cls_name, member.name, member.value, - cls_name, member2.name, member2.value, - cls_name, member3.name, member3.value, - ) - enum_class.__doc__ = classdict['__doc__'] = _dedent("""\ - A collection of name/value pairs. - - Access them by: - - - attribute access:: - - >>> %s.%s - <%s.%s: %r> - - - value lookup: - - >>> %s(%r) - <%s.%s: %r> - - - name lookup: - - >>> %s[%r] - <%s.%s: %r> - - Enumerations can be iterated over, and know how many members they have: - - >>> len(%s) - %r - - >>> %s - %s - - Methods can be added to enumerations, and members can have their own - attributes -- see the documentation for details. - """ - % (cls_name, member.name, - cls_name, member.name, member.value, - cls_name, member.value, - cls_name, member.name, member.value, - cls_name, member.name, - cls_name, member.name, member.value, - cls_name, enum_length, - list_line, list_repr, - )) - # # double check that repr and friends are not the mixin's or various # things break (such as pickle) # however, if the method is defined in the Enum itself, don't replace |