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

Method get_module_attr

mypyc/irbuild/builder.py:554–564  ·  view source on GitHub ↗

Look up an attribute of a module without storing it in the local namespace. For example, get_module_attr('typing', 'TypedDict', line) results in the value of 'typing.TypedDict'. Import the module if needed.

(self, module: str, attr: str, line: int)

Source from the content-addressed store, hash-verified

552 return self.primitive_op(dict_get_item_op, [mod_dict, self.load_str(module, line)], line)
553
554 def get_module_attr(self, module: str, attr: str, line: int) -> Value:
555 """Look up an attribute of a module without storing it in the local namespace.
556
557 For example, get_module_attr('typing', 'TypedDict', line) results in
558 the value of 'typing.TypedDict'.
559
560 Import the module if needed.
561 """
562 self.gen_import(module, line)
563 module_obj = self.get_module(module, line)
564 return self.py_get_attr(module_obj, attr, line)
565
566 def assign_if_null(self, target: Register, get_val: Callable[[], Value], line: int) -> None:
567 """If target is NULL, assign value produced by get_val to it."""

Callers 2

populate_non_ext_basesFunction · 0.80
find_non_ext_metaclassFunction · 0.80

Calls 3

gen_importMethod · 0.95
get_moduleMethod · 0.95
py_get_attrMethod · 0.95

Tested by

no test coverage detected