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

Function get_func_target

mypyc/irbuild/function.py:902–917  ·  view source on GitHub ↗

Given a FuncDef, return the target for the instance of its callable class. If the function was not already defined somewhere, then define it and add it to the current environment.

(builder: IRBuilder, fdef: FuncDef)

Source from the content-addressed store, hash-verified

900
901
902def get_func_target(builder: IRBuilder, fdef: FuncDef) -> AssignmentTarget:
903 """Given a FuncDef, return the target for the instance of its callable class.
904
905 If the function was not already defined somewhere, then define it
906 and add it to the current environment.
907 """
908 if orig := fdef.original_def:
909 if isinstance(orig, Decorator):
910 orig = orig.func
911 # Get the target associated with the previously defined FuncDef.
912 return builder.lookup(orig)
913
914 if builder.fn_info.is_generator or builder.fn_info.add_nested_funcs_to_env:
915 return builder.lookup(fdef)
916
917 return builder.add_local_reg(fdef, object_rprimitive)
918
919
920def load_type(builder: IRBuilder, typ: TypeInfo, unbounded_type: Type | None, line: int) -> Value:

Callers 2

transform_func_defFunction · 0.85
transform_decoratorFunction · 0.85

Calls 3

isinstanceFunction · 0.85
add_local_regMethod · 0.80
lookupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…