Skip to content

Commit 9613cdd

Browse files
committed
First fully working version
1 parent a16edbc commit 9613cdd

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

tools/extract_types.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,40 @@
4747

4848
# Validate that the module is a parseable stub.
4949
total += 1
50+
missing_parameter_type = 0
51+
total_1 = 0
52+
missing_return_type = 0
53+
total_2 = 0
54+
missing_attribute_type = 0
55+
total_3 = 0
5056
try:
5157
tree = astroid.parse(stub_contents)
52-
#print(tree.repr_tree())
5358
for i in tree.body:
5459
for j in i.body:
5560
if isinstance(j, astroid.scoped_nodes.FunctionDef):
56-
argdict = j.args.__dict__
57-
a = argdict.pop('lineno')
58-
a = argdict.pop('col_offset')
59-
a = argdict.pop('parent')
60-
print(argdict)
61+
if None in j.args.__dict__['annotations']:
62+
missing_parameter_type += 1
63+
total_1 += 1
6164
if j.returns:
62-
returndict = j.returns.__dict__
63-
a = returndict.pop('lineno')
64-
a = returndict.pop('col_offset')
65-
a = returndict.pop('parent')
66-
print(returndict)
67-
print('\n')
68-
#print(tree.body[0].body[0])
69-
else:
70-
print(type(j))
65+
if 'Any' in j.returns.__dict__.values():
66+
missing_return_type += 1
67+
total_2 += 1
68+
elif isinstance(j, astroid.node_classes.AnnAssign):
69+
if 'Any' == j.__dict__['annotation'].__dict__['name']:
70+
missing_attribute_type += 1
71+
total_3 += 1
72+
73+
7174
ok += 1
7275
except astroid.exceptions.AstroidSyntaxError as e:
7376
e = e.__cause__
7477
traceback.print_exception(type(e), e, e.__traceback__)
7578
print()
7679

77-
print(f"{ok} ok out of {total}")
80+
print(f"{missing_parameter_type} of {total_1} are missing the parameter type")
81+
print(f"{missing_return_type} of {total_2} are missing the return type")
82+
print(f"{missing_attribute_type} of {total_3} are missing the attribute type")
83+
7884

7985
if ok != total:
8086
sys.exit(total - ok)

0 commit comments

Comments
 (0)