Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _register_injectable(
cls,
klass: type,
filepath: str,
qualifier: str = None,
primary: bool = False,
namespace: str = None,
group: str = None,
singleton: bool = False,
):
unique_id = f"{klass.__qualname__}@{filepath}"
injectable = Injectable(klass, unique_id, primary, group, singleton)
namespace_entry = cls._get_namespace_entry(
namespace or cls.LOADING_DEFAULT_NAMESPACE
)
namespace_entry.register_injectable(injectable, klass, qualifier)
def _register_factory(
cls,
factory: Callable,
filepath: str,
dependency: Optional[type] = None,
qualifier: str = None,
primary: bool = False,
namespace: str = None,
group: str = None,
singleton: bool = False,
):
unique_id = f"{factory.__qualname__}@{filepath}"
injectable = Injectable(factory, unique_id, primary, group, singleton)
namespace_entry = cls._get_namespace_entry(
namespace or cls.LOADING_DEFAULT_NAMESPACE
)
namespace_entry.register_injectable(injectable, dependency, qualifier)
def __init__(self):
self.class_registry: Dict[str, Set[Injectable]] = {}
self.qualifier_registry: Dict[str, Set[Injectable]] = {}