(self, base_id: str, id: str)
| 6809 | return sym |
| 6810 | |
| 6811 | def is_visible_import(self, base_id: str, id: str) -> bool: |
| 6812 | # TODO: can we reuse SCC-level tracking from build.py instead? |
| 6813 | if id in self.import_map[self.cur_mod_id]: |
| 6814 | # Fast path: module is imported locally. |
| 6815 | return True |
| 6816 | if base_id not in self.transitive_submodule_imports: |
| 6817 | # This is a performance optimization for a common pattern. If one module |
| 6818 | # in a codebase uses import numpy as np; np.foo.bar, then it is likely that |
| 6819 | # other modules use similar pattern as well. So we pre-compute transitive |
| 6820 | # dependencies for np, to avoid possible duplicate work in the future. |
| 6821 | self.add_transitive_submodule_imports(base_id) |
| 6822 | if self.cur_mod_id not in self.transitive_submodule_imports: |
| 6823 | self.add_transitive_submodule_imports(self.cur_mod_id) |
| 6824 | return id in self.transitive_submodule_imports[self.cur_mod_id] |
| 6825 | |
| 6826 | def add_transitive_submodule_imports(self, mod_id: str) -> None: |
| 6827 | if mod_id not in self.import_map: |
no test coverage detected