diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index f0c45dab65..d749d202b3 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -54,24 +54,24 @@ def convert_folder(top_level, stub_directory): try: tree = astroid.parse(stub_contents) for i in tree.body: - print(i.__dict__['name']) - for j in i.body: - if isinstance(j, astroid.scoped_nodes.FunctionDef): - if None in j.args.__dict__['annotations']: - print(f"Missing parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}\n") - if j.returns: - if 'Any' in j.returns.__dict__.values(): - print(f"Missing return type: {j.__dict__['name']} on line {j.__dict__['lineno']}") - elif isinstance(j, astroid.node_classes.AnnAssign): - if 'Any' == j.__dict__['annotation'].__dict__['name']: - print(f"missing attribute type on line {j.__dict__['lineno']}") + if 'name' in i.__dict__: + print(i.__dict__['name']) + for j in i.body: + if isinstance(j, astroid.scoped_nodes.FunctionDef): + if None in j.args.__dict__['annotations']: + print(f"Missing parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}\n") + if j.returns: + if 'Any' in j.returns.__dict__.values(): + print(f"Missing return type: {j.__dict__['name']} on line {j.__dict__['lineno']}") + elif isinstance(j, astroid.node_classes.AnnAssign): + if 'name' in j.__dict__['annotation'].__dict__: + if j.__dict__['annotation'].__dict__['name'] == 'Any': + print(f"missing attribute type on line {j.__dict__['lineno']}") ok += 1 except astroid.exceptions.AstroidSyntaxError as e: e = e.__cause__ traceback.print_exception(type(e), e, e.__traceback__) - except KeyError: - print("Function does not have a key: Name") print() return ok, total