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

Function has_nested_func_self_reference

mypyc/irbuild/function.py:314–325  ·  view source on GitHub ↗

Does a nested function contain a self-reference in its body? If a nested function only has references in the surrounding function, we don't need to add it to the environment.

(builder: IRBuilder, fitem: FuncItem)

Source from the content-addressed store, hash-verified

312
313
314def has_nested_func_self_reference(builder: IRBuilder, fitem: FuncItem) -> bool:
315 """Does a nested function contain a self-reference in its body?
316
317 If a nested function only has references in the surrounding function,
318 we don't need to add it to the environment.
319 """
320 if any(isinstance(sym, FuncBase) for sym in builder.free_variables.get(fitem, set())):
321 return True
322 return any(
323 has_nested_func_self_reference(builder, nested)
324 for nested in builder.encapsulating_funcs.get(fitem, [])
325 )
326
327
328def gen_func_ir(

Callers 1

gen_func_itemFunction · 0.85

Calls 4

anyFunction · 0.85
isinstanceFunction · 0.85
setClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…