MCPcopy Create free account
hub / github.com/python/mypy / read

Method read

mypyc/irbuild/builder.py:783–817  ·  view source on GitHub ↗
(
        self,
        target: Value | AssignmentTarget,
        line: int = -1,
        *,
        can_borrow: bool = False,
        allow_error_value: bool = False,
    )

Source from the content-addressed store, hash-verified

781 assert False, "Unsupported lvalue: %r" % lvalue
782
783 def read(
784 self,
785 target: Value | AssignmentTarget,
786 line: int = -1,
787 *,
788 can_borrow: bool = False,
789 allow_error_value: bool = False,
790 ) -> Value:
791 if isinstance(target, Value):
792 return target
793 if isinstance(target, AssignmentTargetRegister):
794 return target.register
795 if isinstance(target, AssignmentTargetIndex):
796 reg = self.gen_method_call(
797 target.base, "__getitem__", [target.index], target.type, line
798 )
799 if reg is not None:
800 return reg
801 assert False, target.base.type
802 if isinstance(target, AssignmentTargetAttr):
803 if isinstance(target.obj.type, RInstance) and target.obj.type.class_ir.is_ext_class:
804 borrow = can_borrow and target.can_borrow
805 return self.add(
806 GetAttr(
807 target.obj,
808 target.attr,
809 line,
810 borrow=borrow,
811 allow_error_value=allow_error_value,
812 )
813 )
814 else:
815 return self.py_get_attr(target.obj, target.attr, line)
816
817 assert False, "Unsupported lvalue: %r" % target
818
819 def read_nullable_attr(self, obj: Value, attr: str, line: int = -1) -> Value:
820 """Read an attribute that might have an error value without raising AttributeError."""

Callers 15

add_var_to_env_classMethod · 0.95
write_fileFunction · 0.45
mypycifyFunction · 0.45
gen_inner_stmtsFunction · 0.45
load_lenMethod · 0.45
gen_conditionMethod · 0.45
gen_conditionMethod · 0.45
try_bodyMethod · 0.45

Calls 5

gen_method_callMethod · 0.95
addMethod · 0.95
py_get_attrMethod · 0.95
GetAttrClass · 0.90
isinstanceFunction · 0.85

Tested by 3

update_testcase_outputFunction · 0.36
run_setupFunction · 0.36