Skip to content

Commit

Permalink
Do not inherit docstrings from standard library classes
Browse files Browse the repository at this point in the history
Implements a missing part of #467
  • Loading branch information
AWhetter committed Aug 29, 2024
1 parent ce69512 commit 2fa7515
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions autoapi/_astroid_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
from collections.abc import Iterable
import itertools
import re
import sys
from typing import Any, NamedTuple

import astroid
import astroid.nodes


if sys.version_info < (3, 10): # PY310
from stdlib_list import in_stdlib
else:

def in_stdlib(module_name: str) -> bool:
return module_name in sys.stdlib_module_names


class ArgInfo(NamedTuple):
prefix: str | None
name: str | None
Expand Down Expand Up @@ -649,12 +658,11 @@ def get_func_docstring(node: astroid.nodes.FunctionDef) -> str:

if not doc and isinstance(node.parent, astroid.nodes.ClassDef):
for base in node.parent.ancestors():
if node.name in ("__init__", "__new__") and base.qname() in (
"__builtins__.object",
"builtins.object",
"builtins.type",
):
continue
if node.name in ("__init__", "__new__"):
base_module = base.qname().split(".", 1)[0]
if in_stdlib(base_module):
continue

for child in base.get_children():
if (
isinstance(child, node.__class__)
Expand Down

0 comments on commit 2fa7515

Please sign in to comment.