Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
__init__.py13 linesDownload Raw Back to utils
1import importlib
2from typing import Type, TypeVar, cast
3
4C = TypeVar("C")
5
6
7def get_class(fqn: str, type: Type[C]) -> Type[C]:
8    """Given a fully qualifed class name, import the module and return the class"""
9    module_name, class_name = fqn.rsplit(".", 1)
10    module = importlib.import_module(module_name)
11    cls = getattr(module, class_name)
12    return cast(Type[C], cls)
13 
codekingpro/portable-devtools · Team Ai