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

Function get_default

mypyc/irbuild/builder.py:1622–1640  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1620 target = builder.lookup(arg.variable)
1621
1622 def get_default() -> Value:
1623 assert arg.initializer is not None
1624
1625 # If it is constant, don't bother storing it
1626 if is_constant(arg.initializer):
1627 return builder.accept(arg.initializer)
1628
1629 # Because gen_arg_defaults runs before calculate_arg_defaults, we
1630 # add the static/attribute to final_names/the class here.
1631 elif not builder.fn_info.is_nested:
1632 name = fitem.fullname + "." + arg.variable.name
1633 builder.final_names.append((name, target.type))
1634 return builder.add(LoadStatic(target.type, name, builder.module_name))
1635 else:
1636 name = arg.variable.name
1637 builder.fn_info.callable_class.ir.attributes[name] = target.type
1638 return builder.add(
1639 GetAttr(builder.fn_info.callable_class.self_reg, name, arg.line)
1640 )
1641
1642 assert isinstance(target, AssignmentTargetRegister), target
1643 reg = target.register

Callers

nothing calls this directly

Calls 6

is_constantFunction · 0.90
LoadStaticClass · 0.90
GetAttrClass · 0.90
appendMethod · 0.80
acceptMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…