diff options
| author | dherrada <dylan.herrada@gmail.com> | 2020-05-15 13:55:46 -0400 |
|---|---|---|
| committer | dherrada <dylan.herrada@gmail.com> | 2020-05-15 13:55:46 -0400 |
| commit | 0e39d4398c95412edd05c7202b7051fe7bd1e2b9 (patch) | |
| tree | ae2ed5b70a6237d0364f82f9946809fcac53e918 /tools/extract_pyi.py | |
| parent | 416da442c073397112b54c8cc10ef6acc8af3197 (diff) | |
Merged extract_types into extract_pyi
Diffstat (limited to 'tools/extract_pyi.py')
| -rw-r--r-- | tools/extract_pyi.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index 95370f761..d6309212a 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -53,12 +53,29 @@ for module in modules: # Validate that the module is a parseable stub. total += 1 try: - astroid.parse(stub_contents) + 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): + a = '' + if None in j.args.__dict__['annotations']: + a += f"Missing parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}\n" + if j.returns: + if 'Any' in j.returns.__dict__.values(): + a += f"Missing return type: {j.__dict__['name']} on line {j.__dict__['lineno']}" + if a: + raise TypeError(a) + elif isinstance(j, astroid.node_classes.AnnAssign): + if 'Any' == j.__dict__['annotation'].__dict__['name']: + raise TypeError(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__) - print() + except TypeError as err: + print(err) print(f"{ok} ok out of {total}") |
