- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad computation of enum superclass in sphinx.ext.autodoc.importer.get_class_members()
#11353
Comments
Please provide a minimal reproducer, ideally a single module file, a single A |
3 files, in the same directory:
Build command, from the same directory: python -m sphinx -b html . out/html Hope that helps. Let me know. |
An enumeration is instantiated as1:
Instead, it is better to use class EnumMixin(enum.Enum):
pass
class MyEnum(EnumMixin, Enum):
a = 1
class Invalid(MyEnum, Enum): # failure
b = 1 The reason why sphinx/sphinx/ext/autodoc/importer.py Lines 228 to 231 in 776d01e
sphinx/sphinx/ext/autodoc/importer.py Lines 245 to 259 in 776d01e
Enumerations override As such, I suggest one of the following:
Footnotes |
Thanks a lot @picnixz for the explanation. |
Describe the bug
The computation for the super-class in
sphinx.ext.autodoc.importer.get_class_members()
is:The version above does not check the super-class taken into account is actually the expected base enum type.
As a consequence, when the super-class is wrong:
_generate_next_value_
,__weakref__
,_member_names_
,_member_map_
,_member_type_
,_value2member_map_
__str__()
for instance.The computation below fixes the thing:
How to Reproduce
git clone https://github.com/alxroyer/scenario/ cd scenario/ python -m sphinx -T -E -b html -D language=en ./tools/conf/sphinx/ ./doc/html/
The problem occurs for the
StrEnum
class.Environment Information
Sphinx extensions
Additional context
No response
The text was updated successfully, but these errors were encountered: