MCPcopy
hub / github.com/django/django / cached_import

Function cached_import

django/utils/module_loading.py:8–16  ·  view source on GitHub ↗
(module_path, class_name)

Source from the content-addressed store, hash-verified

6
7
8def 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
19def import_string(dotted_path):

Callers 1

import_stringFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected