|
47 | 47 |
|
48 | 48 | # Validate that the module is a parseable stub.
|
49 | 49 | 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 |
50 | 56 | try:
|
51 | 57 | tree = astroid.parse(stub_contents)
|
52 |
| - #print(tree.repr_tree()) |
53 | 58 | for i in tree.body:
|
54 | 59 | for j in i.body:
|
55 | 60 | 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 |
61 | 64 | 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 | + |
71 | 74 | ok += 1
|
72 | 75 | except astroid.exceptions.AstroidSyntaxError as e:
|
73 | 76 | e = e.__cause__
|
74 | 77 | traceback.print_exception(type(e), e, e.__traceback__)
|
75 | 78 | print()
|
76 | 79 |
|
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 | + |
78 | 84 |
|
79 | 85 | if ok != total:
|
80 | 86 | sys.exit(total - ok)
|
0 commit comments