Get value from external module given a dotted access path. Only gets value if the module is already imported. Raises: * `KeyError` if module is removed not found, and * `AttributeError` if access path does not match an exported object
(module_name: str, access_path: Sequence[str])
| 125 | |
| 126 | |
| 127 | def _get_external(module_name: str, access_path: Sequence[str]): |
| 128 | """Get value from external module given a dotted access path. |
| 129 | |
| 130 | Only gets value if the module is already imported. |
| 131 | |
| 132 | Raises: |
| 133 | * `KeyError` if module is removed not found, and |
| 134 | * `AttributeError` if access path does not match an exported object |
| 135 | """ |
| 136 | try: |
| 137 | member_type = sys.modules[module_name] |
| 138 | # standard module |
| 139 | for attr in access_path: |
| 140 | member_type = getattr(member_type, attr) |
| 141 | return member_type |
| 142 | except (KeyError, AttributeError): |
| 143 | # handle modules in namespace packages |
| 144 | module_path = ".".join([module_name, *access_path]) |
| 145 | if module_path in sys.modules: |
| 146 | return sys.modules[module_path] |
| 147 | raise |
| 148 | |
| 149 | |
| 150 | def _has_original_dunder_external( |
no outgoing calls
no test coverage detected
searching dependent graphs…