(module_path, class_name)
| 6 | |
| 7 | |
| 8 | def cached_import(module_path, class_name): |
| 9 | # Check whether module is loaded and fully initialized. |
| 10 | if not ( |
| 11 | (module := sys.modules.get(module_path)) |
| 12 | and (spec := getattr(module, "__spec__", None)) |
| 13 | and getattr(spec, "_initializing", False) is False |
| 14 | ): |
| 15 | module = import_module(module_path) |
| 16 | return getattr(module, class_name) |
| 17 | |
| 18 | |
| 19 | def import_string(dotted_path): |