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)
| 46 | |
| 47 | |
| 48 | def 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 | |
| 73 | def generate_annotations_json(source_path, target_path, only_simple=False): |