From d1664bdde2764e1a72a792dcfb23d4b650085e97 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 2 Jul 2020 10:25:20 -0400 Subject: Fixed extract_pyi script to allow NoneType --- tools/extract_pyi.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index d749d202b..131cef15f 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -1,3 +1,7 @@ +# Run with 'python tools/extract_pyi.py shared-bindings/ path/to/stub/dir +# You can also test a specific library in shared-bindings by putting the path +# to that directory instead + import os import sys import astroid @@ -58,8 +62,10 @@ def convert_folder(top_level, stub_directory): 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") + for i in j.args.__dict__['annotations']: + if type(i) == astroid.node_classes.Name: + if i.name == 'Any': + 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']}") -- cgit v1.2.3 From 1e96ca582ee1d5e728dd6cd8b744a40ea1c98fe5 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 2 Jul 2020 11:10:43 -0400 Subject: Made more modifications to extract_pyi.py --- tools/extract_pyi.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index 131cef15f..9d22af93a 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -62,10 +62,14 @@ def convert_folder(top_level, stub_directory): print(i.__dict__['name']) for j in i.body: if isinstance(j, astroid.scoped_nodes.FunctionDef): - for i in j.args.__dict__['annotations']: - if type(i) == astroid.node_classes.Name: - if i.name == 'Any': + for k, l in zip(j.args.__dict__['annotations'], j.args.__dict__['args']): + # K is type, l is name + if l.name != 'self': + if not k: print(f"Missing parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}\n") + elif str(type(k)) == "": + if k.name == 'Any': + print(f"'Any' 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']}") -- cgit v1.2.3 From 427733af04fa4d9d2075ec98e4083c48d1469695 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 2 Jul 2020 11:30:42 -0400 Subject: More tweaks to extract_pyi.py --- tools/extract_pyi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index 9d22af93a..1781cbd10 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -76,7 +76,7 @@ def convert_folder(top_level, stub_directory): 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']}") + print(f"missing attribute type: {j.__dict__['target'].name} on line {j.__dict__['lineno']}") ok += 1 except astroid.exceptions.AstroidSyntaxError as e: -- cgit v1.2.3 From e169da3532f646e2498f2b326a52aeff896ae170 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 2 Jul 2020 12:01:28 -0400 Subject: More extract_pyi tweaks --- tools/extract_pyi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index 1781cbd10..f504e634e 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -59,6 +59,7 @@ def convert_folder(top_level, stub_directory): tree = astroid.parse(stub_contents) for i in tree.body: if 'name' in i.__dict__: + print() print(i.__dict__['name']) for j in i.body: if isinstance(j, astroid.scoped_nodes.FunctionDef): @@ -66,10 +67,10 @@ def convert_folder(top_level, stub_directory): # K is type, l is name if l.name != 'self': if not k: - print(f"Missing parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}\n") + print(f"Missing parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}") elif str(type(k)) == "": if k.name == 'Any': - print(f"'Any' parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}\n") + print(f"'Any' parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}") if j.returns: if 'Any' in j.returns.__dict__.values(): print(f"Missing return type: {j.__dict__['name']} on line {j.__dict__['lineno']}") -- cgit v1.2.3