def import_string(dotted_path: str) -> Any:
try:<EOL><INDENT>module_path, class_name = dotted_path.rsplit("<STR_LIT:.>", <NUM_LIT:1>)<EOL><DEDENT>except ValueError:<EOL><INDENT>msg = "<STR_LIT>" % dotted_path<EOL>raise ImportError(msg)<EOL><DEDENT>module = import_module(module_path)<EOL>try:<EOL><INDENT>return getattr(module, class_name)<EOL><DEDENT>except AttributeError:<EOL><INDENT>msg = '<STR_LIT>' % (<EOL>module_path,<EOL>class_name,<EOL>)<EOL>raise ImportError(msg)<EOL><DEDENT>
Source: django.utils.module_loading
Import a dotted module path and return the attribute/class designated by the
last name in the path. Raise ImportError if the import failed.