Dump annotations out of type_info, filtered by files. If files is non-empty, only dump items either if the path in the item matches one of the files exactly, or else if one of the files is a path prefix of the path.
(type_info, files)
| 60 | |
| 61 | |
| 62 | def dump_annotations(type_info, files): |
| 63 | """Dump annotations out of type_info, filtered by files. |
| 64 | |
| 65 | If files is non-empty, only dump items either if the path in the |
| 66 | item matches one of the files exactly, or else if one of the files |
| 67 | is a path prefix of the path. |
| 68 | """ |
| 69 | with open(type_info) as f: |
| 70 | data = json.load(f) |
| 71 | for item in data: |
| 72 | path, line, func_name = item['path'], item['line'], item['func_name'] |
| 73 | if files and path not in files: |
| 74 | for f in files: |
| 75 | if path.startswith(os.path.join(f, '')): |
| 76 | break |
| 77 | else: |
| 78 | continue # Outer loop |
| 79 | print("%s:%d: in %s:" % (path, line, func_name)) |
| 80 | type_comments = item['type_comments'] |
| 81 | signature = unify_type_comments(type_comments) |
| 82 | arg_types = signature['arg_types'] |
| 83 | return_type = signature['return_type'] |
| 84 | print(" # type: (%s) -> %s" % (", ".join(arg_types), return_type)) |
| 85 | |
| 86 | |
| 87 | def main(args_override=None): |
no test coverage detected