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

Function deserialize_modules

mypyc/ir/module_ir.py:106–138  ·  view source on GitHub ↗

Deserialize a collection of modules. The modules can contain dependencies on each other. Arguments: data: A dict containing the modules to deserialize. ctx: The deserialization maps to use and to populate. They are populated with information from the deserializ

(data: dict[str, JsonDict], ctx: DeserMaps)

Source from the content-addressed store, hash-verified

104
105
106def deserialize_modules(data: dict[str, JsonDict], ctx: DeserMaps) -> dict[str, ModuleIR]:
107 """Deserialize a collection of modules.
108
109 The modules can contain dependencies on each other.
110
111 Arguments:
112 data: A dict containing the modules to deserialize.
113 ctx: The deserialization maps to use and to populate.
114 They are populated with information from the deserialized
115 modules and as a precondition must have been populated by
116 deserializing any dependencies of the modules being deserialized
117 (outside of dependencies between the modules themselves).
118
119 Returns a map containing the deserialized modules.
120 """
121 for mod in data.values():
122 # First create ClassIRs for every class so that we can construct types and whatnot
123 for cls in mod["classes"]:
124 ir = ClassIR(cls["name"], cls["module_name"])
125 assert ir.fullname not in ctx.classes, "Class %s already in map" % ir.fullname
126 ctx.classes[ir.fullname] = ir
127
128 for mod in data.values():
129 # Then deserialize all of the functions so that methods are available
130 # to the class deserialization.
131 for method in mod["functions"]:
132 func = FuncIR.deserialize(method, ctx)
133 assert func.decl.id not in ctx.functions, (
134 "Method %s already in map" % func.decl.fullname
135 )
136 ctx.functions[func.decl.id] = func
137
138 return {k: ModuleIR.deserialize(v, ctx) for k, v in data.items()}
139
140
141# ModulesIRs should also always be an *OrderedDict*, but if we

Callers 2

load_scc_from_cacheFunction · 0.90

Calls 4

ClassIRClass · 0.90
valuesMethod · 0.80
deserializeMethod · 0.45
itemsMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…