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

Function gen_property_setter_ir

mypyc/irbuild/function.py:1204–1222  ·  view source on GitHub ↗

Generate an implicit trivial property setter for an attribute. These are used if an attribute can also be accessed as a property.

(
    builder: IRBuilder, func_decl: FuncDecl, cdef: ClassDef, is_trait: bool
)

Source from the content-addressed store, hash-verified

1202
1203
1204def gen_property_setter_ir(
1205 builder: IRBuilder, func_decl: FuncDecl, cdef: ClassDef, is_trait: bool
1206) -> FuncIR:
1207 """Generate an implicit trivial property setter for an attribute.
1208
1209 These are used if an attribute can also be accessed as a property.
1210 """
1211 name = func_decl.name
1212 builder.enter(name)
1213 self_reg = builder.add_argument("self", func_decl.sig.args[0].type)
1214 value_reg = builder.add_argument("value", func_decl.sig.args[1].type)
1215 assert name.startswith(PROPSET_PREFIX)
1216 attr_name = name[len(PROPSET_PREFIX) :]
1217 line = func_decl._line or -1
1218 if not is_trait:
1219 builder.add(SetAttr(self_reg, attr_name, value_reg, line))
1220 builder.add(Return(builder.none(), line))
1221 args, _, blocks, ret_type, fn_info = builder.leave()
1222 return FuncIR(func_decl, args, blocks, line)

Callers 1

transform_class_defFunction · 0.90

Calls 10

SetAttrClass · 0.90
ReturnClass · 0.90
FuncIRClass · 0.90
lenFunction · 0.85
add_argumentMethod · 0.80
leaveMethod · 0.80
enterMethod · 0.45
startswithMethod · 0.45
addMethod · 0.45
noneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…