First fully working version
This commit is contained in:
parent
a16edbc45c
commit
9613cdd184
@ -47,34 +47,40 @@ for module in modules:
|
|||||||
|
|
||||||
# Validate that the module is a parseable stub.
|
# Validate that the module is a parseable stub.
|
||||||
total += 1
|
total += 1
|
||||||
|
missing_parameter_type = 0
|
||||||
|
total_1 = 0
|
||||||
|
missing_return_type = 0
|
||||||
|
total_2 = 0
|
||||||
|
missing_attribute_type = 0
|
||||||
|
total_3 = 0
|
||||||
try:
|
try:
|
||||||
tree = astroid.parse(stub_contents)
|
tree = astroid.parse(stub_contents)
|
||||||
#print(tree.repr_tree())
|
|
||||||
for i in tree.body:
|
for i in tree.body:
|
||||||
for j in i.body:
|
for j in i.body:
|
||||||
if isinstance(j, astroid.scoped_nodes.FunctionDef):
|
if isinstance(j, astroid.scoped_nodes.FunctionDef):
|
||||||
argdict = j.args.__dict__
|
if None in j.args.__dict__['annotations']:
|
||||||
a = argdict.pop('lineno')
|
missing_parameter_type += 1
|
||||||
a = argdict.pop('col_offset')
|
total_1 += 1
|
||||||
a = argdict.pop('parent')
|
|
||||||
print(argdict)
|
|
||||||
if j.returns:
|
if j.returns:
|
||||||
returndict = j.returns.__dict__
|
if 'Any' in j.returns.__dict__.values():
|
||||||
a = returndict.pop('lineno')
|
missing_return_type += 1
|
||||||
a = returndict.pop('col_offset')
|
total_2 += 1
|
||||||
a = returndict.pop('parent')
|
elif isinstance(j, astroid.node_classes.AnnAssign):
|
||||||
print(returndict)
|
if 'Any' == j.__dict__['annotation'].__dict__['name']:
|
||||||
print('\n')
|
missing_attribute_type += 1
|
||||||
#print(tree.body[0].body[0])
|
total_3 += 1
|
||||||
else:
|
|
||||||
print(type(j))
|
|
||||||
ok += 1
|
ok += 1
|
||||||
except astroid.exceptions.AstroidSyntaxError as e:
|
except astroid.exceptions.AstroidSyntaxError as e:
|
||||||
e = e.__cause__
|
e = e.__cause__
|
||||||
traceback.print_exception(type(e), e, e.__traceback__)
|
traceback.print_exception(type(e), e, e.__traceback__)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
print(f"{ok} ok out of {total}")
|
print(f"{missing_parameter_type} of {total_1} are missing the parameter type")
|
||||||
|
print(f"{missing_return_type} of {total_2} are missing the return type")
|
||||||
|
print(f"{missing_attribute_type} of {total_3} are missing the attribute type")
|
||||||
|
|
||||||
|
|
||||||
if ok != total:
|
if ok != total:
|
||||||
sys.exit(total - ok)
|
sys.exit(total - ok)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user