Skip to content

Commit 2fa7515

Browse files
committed
Do not inherit docstrings from standard library classes
Implements a missing part of #467
1 parent ce69512 commit 2fa7515

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

autoapi/_astroid_utils.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@
44
from collections.abc import Iterable
55
import itertools
66
import re
7+
import sys
78
from typing import Any, NamedTuple
89

910
import astroid
1011
import astroid.nodes
1112

1213

14+
if sys.version_info < (3, 10): # PY310
15+
from stdlib_list import in_stdlib
16+
else:
17+
18+
def in_stdlib(module_name: str) -> bool:
19+
return module_name in sys.stdlib_module_names
20+
21+
1322
class ArgInfo(NamedTuple):
1423
prefix: str | None
1524
name: str | None
@@ -649,12 +658,11 @@ def get_func_docstring(node: astroid.nodes.FunctionDef) -> str:
649658

650659
if not doc and isinstance(node.parent, astroid.nodes.ClassDef):
651660
for base in node.parent.ancestors():
652-
if node.name in ("__init__", "__new__") and base.qname() in (
653-
"__builtins__.object",
654-
"builtins.object",
655-
"builtins.type",
656-
):
657-
continue
661+
if node.name in ("__init__", "__new__"):
662+
base_module = base.qname().split(".", 1)[0]
663+
if in_stdlib(base_module):
664+
continue
665+
658666
for child in base.get_children():
659667
if (
660668
isinstance(child, node.__class__)

0 commit comments

Comments
 (0)