MCPcopy Index your code
hub / github.com/python/mypy / serialize

Method serialize

mypyc/ir/class_ir.py:380–437  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

378 return any(ci._serializable for ci in self.mro)
379
380 def serialize(self) -> JsonDict:
381 return {
382 "name": self.name,
383 "module_name": self.module_name,
384 "is_trait": self.is_trait,
385 "is_ext_class": self.is_ext_class,
386 "is_abstract": self.is_abstract,
387 "is_generated": self.is_generated,
388 "is_augmented": self.is_augmented,
389 "is_final_class": self.is_final_class,
390 "inherits_python": self.inherits_python,
391 "has_dict": self.has_dict,
392 "allow_interpreted_subclasses": self.allow_interpreted_subclasses,
393 "needs_getseters": self.needs_getseters,
394 "_serializable": self._serializable,
395 "builtin_base": self.builtin_base,
396 "ctor": self.ctor.serialize(),
397 # We serialize dicts as lists to ensure order is preserved
398 "attributes": [(k, t.serialize()) for k, t in self.attributes.items()],
399 # We try to serialize a name reference, but if the decl isn't in methods
400 # then we can't be sure that will work so we serialize the whole decl.
401 "method_decls": [
402 (k, d.id if k in self.methods else d.serialize())
403 for k, d in self.method_decls.items()
404 ],
405 # We serialize method fullnames out and put methods in a separate dict
406 "methods": [(k, m.id) for k, m in self.methods.items()],
407 "glue_methods": [
408 ((cir.fullname, k), m.id) for (cir, k), m in self.glue_methods.items()
409 ],
410 # We serialize properties and property_types separately out of an
411 # abundance of caution about preserving dict ordering...
412 "property_types": [(k, t.serialize()) for k, t in self.property_types.items()],
413 "properties": list(self.properties),
414 "vtable": self.vtable,
415 "vtable_entries": serialize_vtable(self.vtable_entries),
416 "trait_vtables": [
417 (cir.fullname, serialize_vtable(v)) for cir, v in self.trait_vtables.items()
418 ],
419 # References to class IRs are all just names
420 "base": self.base.fullname if self.base else None,
421 "traits": [cir.fullname for cir in self.traits],
422 "mro": [cir.fullname for cir in self.mro],
423 "base_mro": [cir.fullname for cir in self.base_mro],
424 "children": (
425 [cir.fullname for cir in self.children] if self.children is not None else None
426 ),
427 "deletable": self.deletable,
428 "attrs_with_defaults": sorted(self.attrs_with_defaults),
429 "_always_initialized_attrs": sorted(self._always_initialized_attrs),
430 "_sometimes_initialized_attrs": sorted(self._sometimes_initialized_attrs),
431 "init_self_leak": self.init_self_leak,
432 "env_user_function": self.env_user_function.id if self.env_user_function else None,
433 "reuse_freed_instance": self.reuse_freed_instance,
434 "is_acyclic": self.is_acyclic,
435 "is_enum": self.is_enum,
436 "is_coroutine": self.coroutine_name,
437 }

Callers

nothing calls this directly

Calls 4

listClass · 0.85
serialize_vtableFunction · 0.85
sortedFunction · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected