blob: c08f970f28071f4411a30fc24e9cbd3072248fc8 [file] [log] [blame]
{
"meta_a": {
"name": "test_file.py",
"content_type": "text/x-python",
"lines": 42
},
"meta_b": {
"name": "test_file.py",
"content_type": "text/x-python",
"lines": 42
},
"change_type": "MODIFIED",
"diff_header": [
"diff --git a/test_file.py b/test_file.py",
"index 3af5d07..0c975d6 100644",
"--- a/test_file.py",
"+++ b/test_file.py"
],
"content": [
{
"ab": [
"from types import Any, Callable, Type, Union",
"",
"__all__ = [\"importclass\", \"preprocess_classes\", \"TypeClassOrPath\"]",
"",
"TypeClassOrPath = Union[Type, str]",
"",
"",
"def importclass(",
" module_name: str,",
" class_name: Union[str, None] = None",
") -> Type:",
" \"\"\"",
" Dynamically import a class from a specified module.",
"",
" :param module_name: The name of the module to import.",
" :param class_name: The name of the class in the module to import. Defaults to None.",
" :return: The dynamically imported class.",
" \"\"\"",
" if not class_name:",
" module_name, class_name = module_name.rsplit('.', 1)",
" loaded_module = importclass(module_name, fromlist=[class_name])"
]
},
{
"a": [
" return getattr(loaded_module, class_name)"
],
"b": [
" return getattr(loaded_module, class_name)"
],
"common": true
},
{
"ab": [
"def preprocess_classes(func: Callable) -> Callable:",
" classes_processed = (",
" class_id if isinstance(class_id, type)",
" else importclass(class_id)",
" for class_id in all_classes",
" )",
" return func(*classes_processed, kwargs)",
" return __preprocess_classes_wrapper"
]
}
]
}