From e7e08d2a784d1e87aded58186bff776d6de42213 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 18 Dec 2021 15:22:10 +0900 Subject: Fix #9968: autodoc: ivars are not shown if __init__ has posonlyargs --- sphinx/pycode/parser.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sphinx/pycode') diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py index cad9a6e71..6b566c4c4 100644 --- a/sphinx/pycode/parser.py +++ b/sphinx/pycode/parser.py @@ -312,6 +312,10 @@ class VariableCommentPicker(ast.NodeVisitor): """Returns the name of the first argument if in a function.""" if self.current_function and self.current_function.args.args: return self.current_function.args.args[0] + elif (self.current_function and + getattr(self.current_function.args, 'posonlyargs', None)): + # for py38+ + return self.current_function.args.posonlyargs[0] # type: ignore else: return None -- cgit v1.2.3