Skip to content

Commit

Permalink
construct a fake function and use ast.parse to extract the args (Padd…
Browse files Browse the repository at this point in the history
  • Loading branch information
wadefelix authored Apr 1, 2022
1 parent 5830039 commit 118c6c0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions ci_scripts/check_api_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import re
import sys
import inspect
import ast
import paddle


Expand Down Expand Up @@ -61,15 +62,10 @@ def _check_params_in_description(rstfilename, paramstr):
flag = True
params_intitle = []
if paramstr:
_params_intitle = paramstr.split(
', '
) # is there any parameter with default value of type list/tuple? may break this.
for s in _params_intitle:
if ':' in s: # annotations
pname = s.split(':')
params_intitle.append(pname[0].strip())
else:
params_intitle.append(s.strip())
fake_func = ast.parse(f'def fake_func({paramstr}): pass')
for arg in fake_func.body[0].args.args:
params_intitle.append(arg.arg)

funcdescnode = extract_params_desc_from_rst_file(rstfilename)
if funcdescnode:
items = funcdescnode.children[1].children[0].children
Expand Down

0 comments on commit 118c6c0

Please sign in to comment.