@@ -37,7 +37,7 @@ def visit_functiondef(
3737 This function takes a function definition node and visits its contents,
3838 particularly its decorators, to build up the documentation metadata.
3939 """
40- function : Function = self .visitor .current .members [node .name ] # type: ignore[assignment]
40+ func : Function = self .visitor .current .members [node .name ] # type: ignore[assignment]
4141
4242 func_doc = {}
4343 for decorator_node in node .decorator_list :
@@ -46,20 +46,18 @@ def visit_functiondef(
4646
4747 params_doc : dict [str , dict [str , Any ]] = defaultdict (dict )
4848 for arg in node .args .args :
49- if isinstance (arg .annotation , ast .Subscript ):
50- if arg .annotation .value .id == "Annotated" : # type: ignore[attr-defined]
51- param_name = arg .arg
52- params_doc [param_name ]["annotation" ] = safe_get_annotation (
53- arg .annotation .slice .elts [0 ], # type: ignore[attr-defined]
54- function .parent , # type: ignore[arg-type]
55- )
56- doc = arg .annotation .slice .elts [1 ] # type: ignore[attr-defined]
57- if isinstance (doc , ast .Call ):
58- if doc .func .id == "__typing_doc__" : # type: ignore[attr-defined]
59- params_doc [param_name ].update ({kw .arg : kw .value .value for kw in doc .keywords }) # type: ignore[attr-defined,misc]
49+ if isinstance (arg .annotation , ast .Subscript ) and arg .annotation .value .id == "Annotated" : # type: ignore[attr-defined]
50+ param_name = arg .arg
51+ params_doc [param_name ]["annotation" ] = safe_get_annotation (
52+ arg .annotation .slice .elts [0 ], # type: ignore[attr-defined]
53+ func .parent ,
54+ )
55+ doc = arg .annotation .slice .elts [1 ] # type: ignore[attr-defined]
56+ if isinstance (doc , ast .Call ) and doc .func .id == "__typing_doc__" : # type: ignore[attr-defined]
57+ params_doc [param_name ].update ({kw .arg : kw .value .value for kw in doc .keywords }) # type: ignore[attr-defined,misc]
6058
61- if (func_doc or params_doc ) and function .docstring :
62- sections = function .docstring .parsed
59+ if (func_doc or params_doc ) and func .docstring :
60+ sections = func .docstring .parsed
6361 if params_doc :
6462 docstring_params = []
6563 for param_name , param_doc in params_doc .items ():
@@ -68,7 +66,7 @@ def visit_functiondef(
6866 name = param_name ,
6967 description = param_doc ["description" ],
7068 annotation = param_doc ["annotation" ],
71- value = function .parameters [param_name ].default ,
69+ value = func .parameters [param_name ].default , # type: ignore[arg-type]
7270 ),
7371 )
7472 sections .append (DocstringSectionParameters (docstring_params ))
0 commit comments