MCPcopy Create free account
hub / github.com/dropbox/pyannotate / dump_annotations

Function dump_annotations

pyannotate_tools/annotations/__main__.py:62–84  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

60
61
62def 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
87def main(args_override=None):

Callers 1

mainFunction · 0.85

Calls 1

unify_type_commentsFunction · 0.90

Tested by

no test coverage detected