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)
| 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.""" |
no test coverage detected