Merge pull request #9493 from tk0miya/9436_autodoc_class_signature

Fix #9436, #9471: autodoc: crashed if autodoc_class_signature = "separated"
This commit is contained in:
Takeshi KOMIYA 2021-07-25 19:08:53 +09:00 committed by GitHub
commit 5d8f925e02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -23,6 +23,7 @@ Bugs fixed
with the HEAD of 3.10
* #9490: autodoc: Some objects under ``typing`` module are not displayed well
with the HEAD of 3.10
* #9436, #9471: autodoc: crashed if ``autodoc_class_signature = "separated"``
* #9435: linkcheck: Failed to check anchors in github.com
Testing

View File

@ -257,6 +257,9 @@ def between(marker: str, what: Sequence[str] = None, keepempty: bool = False,
# But we define this class here to keep compatibility (see #4538)
class Options(dict):
"""A dict/attribute hybrid that returns None on nonexisting keys."""
def copy(self) -> "Options":
return Options(super().copy())
def __getattr__(self, name: str) -> Any:
try:
return self[name.replace('_', '-')]
@ -1445,9 +1448,11 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
super().__init__(*args)
if self.config.autodoc_class_signature == 'separated':
self.options = self.options.copy()
# show __init__() method
if self.options.special_members is None:
self.options['special-members'] = {'__new__', '__init__'}
self.options['special-members'] = ['__new__', '__init__']
else:
self.options.special_members.append('__new__')
self.options.special_members.append('__init__')