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

Class AssignmentTargetAttr

mypyc/irbuild/targets.py:41–59  ·  view source on GitHub ↗

obj.attr as assignment target

Source from the content-addressed store, hash-verified

39
40
41class AssignmentTargetAttr(AssignmentTarget):
42 """obj.attr as assignment target"""
43
44 def __init__(self, obj: Value, attr: str, can_borrow: bool = False) -> None:
45 self.obj = obj
46 self.attr = attr
47 self.can_borrow = can_borrow
48 if isinstance(obj.type, RInstance) and obj.type.class_ir.has_attr(attr):
49 # Native attribute reference
50 self.obj_type: RType = obj.type
51 self.type = obj.type.attr_type(attr)
52 else:
53 # Python attribute reference
54 self.obj_type = object_rprimitive
55 self.type = object_rprimitive
56
57 def __repr__(self) -> str:
58 can_borrow_str = ", can_borrow=True" if self.can_borrow else ""
59 return f"AssignmentTargetAttr({self.obj!r}.{self.attr}{can_borrow_str})"
60
61
62class AssignmentTargetTuple(AssignmentTarget):

Callers 3

load_outer_envFunction · 0.90
get_assignment_targetMethod · 0.90
add_var_to_env_classMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…