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

Function generate_annotations_json_string

pyannotate_tools/annotations/main.py:48–70  ·  view source on GitHub ↗

Produce annotation data JSON file from a JSON file with runtime-collected types. Data formats: * The source JSON is a list of pyannotate_tools.annotations.parse.RawEntry items. * The output JSON is a list of FunctionData items.

(source_path, only_simple=False)

Source from the content-addressed store, hash-verified

46
47
48def generate_annotations_json_string(source_path, only_simple=False):
49 # type: (str, bool) -> List[FunctionData]
50 """Produce annotation data JSON file from a JSON file with runtime-collected types.
51
52 Data formats:
53
54 * The source JSON is a list of pyannotate_tools.annotations.parse.RawEntry items.
55 * The output JSON is a list of FunctionData items.
56 """
57 items = parse_json(source_path)
58 results = []
59 for item in items:
60 signature = unify_type_comments(item.type_comments)
61 if is_signature_simple(signature) or not only_simple:
62 data = {
63 'path': item.path,
64 'line': item.line,
65 'func_name': item.func_name,
66 'signature': signature,
67 'samples': item.samples
68 } # type: FunctionData
69 results.append(data)
70 return results
71
72
73def generate_annotations_json(source_path, target_path, only_simple=False):

Callers 4

mainFunction · 0.90

Calls 3

parse_jsonFunction · 0.90
unify_type_commentsFunction · 0.85
is_signature_simpleFunction · 0.85

Tested by 2