diff --git a/sphinx/ext/autodoc/preserve_defaults.py b/sphinx/ext/autodoc/preserve_defaults.py index 295c7f9468e..c633781085f 100644 --- a/sphinx/ext/autodoc/preserve_defaults.py +++ b/sphinx/ext/autodoc/preserve_defaults.py @@ -46,10 +46,10 @@ def get_arguments(obj: Any) -> ast.arguments | None: # subject is placed inside class or block. To read its docstring, # this adds if-block before the declaration. module = ast.parse('if True:\n' + source) - subject = module.body[0].body[0] + subject = module.body[0].body[0] # type: ignore[attr-defined] else: module = ast.parse(source) - subject = module.body[0] + subject = module.body[0] # type: ignore[attr-defined] except (OSError, TypeError): # failed to load source code return None except SyntaxError: @@ -67,7 +67,7 @@ def get_arguments(obj: Any) -> ast.arguments | None: # propagated). raise - def _get_arguments(x: ast.AST) -> ast.arguments | None: + def _get_arguments(x: Any) -> ast.arguments | None: if isinstance(x, (ast.AsyncFunctionDef, ast.FunctionDef, ast.Lambda)): return x.args if isinstance(x, (ast.Assign, ast.AnnAssign)):