MCPcopy Create free account
hub / github.com/python/mypy / finalize_env_class

Function finalize_env_class

mypyc/irbuild/env_class.py:69–83  ·  view source on GitHub ↗

Generate, instantiate, and set up the environment of an environment class.

(builder: IRBuilder, prefix: str = "")

Source from the content-addressed store, hash-verified

67
68
69def finalize_env_class(builder: IRBuilder, prefix: str = "") -> None:
70 """Generate, instantiate, and set up the environment of an environment class."""
71 if not builder.fn_info.can_merge_generator_and_env_classes():
72 instantiate_env_class(builder)
73
74 # Iterate through the function arguments and replace local definitions (using registers)
75 # that were previously added to the environment with references to the function's
76 # environment class. Comprehension scopes have no arguments to add.
77 if not builder.fn_info.is_comprehension_scope:
78 if builder.fn_info.is_nested:
79 add_args_to_env(
80 builder, local=False, base=builder.fn_info.callable_class, prefix=prefix
81 )
82 else:
83 add_args_to_env(builder, local=False, base=builder.fn_info, prefix=prefix)
84
85
86def instantiate_env_class(builder: IRBuilder) -> Value:

Callers 3

gen_func_bodyFunction · 0.90
gen_generator_funcFunction · 0.90

Calls 3

instantiate_env_classFunction · 0.85
add_args_to_envFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…