| 1163 | return visitor.visit_func_def(self) |
| 1164 | |
| 1165 | def serialize(self) -> JsonDict: |
| 1166 | # We're deliberating omitting arguments and storing only arg_names and |
| 1167 | # arg_kinds for space-saving reasons (arguments is not used in later |
| 1168 | # stages of mypy). |
| 1169 | # TODO: After a FuncDef is deserialized, the only time we use `arg_names` |
| 1170 | # and `arg_kinds` is when `type` is None and we need to infer a type. Can |
| 1171 | # we store the inferred type ahead of time? |
| 1172 | return { |
| 1173 | ".class": "FuncDef", |
| 1174 | "name": self._name, |
| 1175 | "fullname": self._fullname, |
| 1176 | "arg_names": self.arg_names, |
| 1177 | "arg_kinds": [int(x.value) for x in self.arg_kinds], |
| 1178 | "type": None if self.type is None else self.type.serialize(), |
| 1179 | "flags": get_flags(self, FUNCDEF_FLAGS), |
| 1180 | "abstract_status": self.abstract_status, |
| 1181 | # TODO: Do we need expanded, original_def? |
| 1182 | "dataclass_transform_spec": ( |
| 1183 | None |
| 1184 | if self.dataclass_transform_spec is None |
| 1185 | else self.dataclass_transform_spec.serialize() |
| 1186 | ), |
| 1187 | "deprecated": self.deprecated, |
| 1188 | "original_first_arg": self.original_first_arg, |
| 1189 | } |
| 1190 | |
| 1191 | @classmethod |
| 1192 | def deserialize(cls, data: JsonDict) -> FuncDef: |