diff --git a/src/cpl_core/configuration/configuration.py b/src/cpl_core/configuration/configuration.py index a8372cac..aa3eab53 100644 --- a/src/cpl_core/configuration/configuration.py +++ b/src/cpl_core/configuration/configuration.py @@ -294,7 +294,7 @@ class Configuration(ConfigurationABC): self.add_configuration(sub, configuration) - def add_configuration(self, key_type: T, value: any): + def add_configuration(self, key_type: Type[T], value: any): self._config[key_type] = value def create_console_argument( diff --git a/src/cpl_core/configuration/configuration_abc.py b/src/cpl_core/configuration/configuration_abc.py index 815fa361..96ae8401 100644 --- a/src/cpl_core/configuration/configuration_abc.py +++ b/src/cpl_core/configuration/configuration_abc.py @@ -77,7 +77,7 @@ class ConfigurationABC(ABC): pass @abstractmethod - def add_configuration(self, key_type: T, value: any): + def add_configuration(self, key_type: Type[T], value: any): r"""Add configuration object Parameter: diff --git a/src/cpl_core/dependency_injection/service_collection.py b/src/cpl_core/dependency_injection/service_collection.py index acdf099f..4f6be8c7 100644 --- a/src/cpl_core/dependency_injection/service_collection.py +++ b/src/cpl_core/dependency_injection/service_collection.py @@ -61,15 +61,15 @@ class ServiceCollection(ServiceCollectionABC): self.add_transient(PipeABC, pipe) return self - def add_singleton(self, service_type: T, service: T = None): + def add_singleton(self, service_type: Type[T], service: T = None): self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.singleton, service) return self - def add_scoped(self, service_type: T, service: Callable = None): + def add_scoped(self, service_type: Type[T], service: Callable = None): self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.scoped, service) return self - def add_transient(self, service_type: T, service: T = None): + def add_transient(self, service_type: Type[T], service: T = None): self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.transient, service) return self diff --git a/src/cpl_core/dependency_injection/service_collection_abc.py b/src/cpl_core/dependency_injection/service_collection_abc.py index 8da9a519..62c1b5a8 100644 --- a/src/cpl_core/dependency_injection/service_collection_abc.py +++ b/src/cpl_core/dependency_injection/service_collection_abc.py @@ -46,7 +46,7 @@ class ServiceCollectionABC(ABC): pass @abstractmethod - def add_transient(self, service_type: T, service: T = None) -> "ServiceCollectionABC": + def add_transient(self, service_type: Type[T], service: T = None) -> "ServiceCollectionABC": r"""Adds a service with transient lifetime Parameter: @@ -61,7 +61,7 @@ class ServiceCollectionABC(ABC): pass @abstractmethod - def add_scoped(self, service_type: T, service: T = None) -> "ServiceCollectionABC": + def add_scoped(self, service_type: Type[T], service: T = None) -> "ServiceCollectionABC": r"""Adds a service with scoped lifetime Parameter: @@ -76,7 +76,7 @@ class ServiceCollectionABC(ABC): pass @abstractmethod - def add_singleton(self, service_type: T, service: T = None) -> "ServiceCollectionABC": + def add_singleton(self, service_type: Type[T], service: T = None) -> "ServiceCollectionABC": r"""Adds a service with singleton lifetime Parameter: diff --git a/src/cpl_core/dependency_injection/service_provider.py b/src/cpl_core/dependency_injection/service_provider.py index 8084b936..ac1225db 100644 --- a/src/cpl_core/dependency_injection/service_provider.py +++ b/src/cpl_core/dependency_injection/service_provider.py @@ -138,7 +138,7 @@ class ServiceProvider(ServiceProviderABC): sb = ScopeBuilder(ServiceProvider(descriptors, self._configuration, self._database_context)) return sb.build() - def get_service(self, service_type: T, *args, **kwargs) -> Optional[T]: + def get_service(self, service_type: typing.Type[T], *args, **kwargs) -> Optional[T]: result = self._find_service(service_type) if result is None: @@ -157,7 +157,7 @@ class ServiceProvider(ServiceProviderABC): return implementation - def get_services(self, service_type: T, *args, **kwargs) -> list[Optional[T]]: + def get_services(self, service_type: typing.Type[T], *args, **kwargs) -> list[Optional[T]]: implementations = [] if typing.get_origin(service_type) != list: diff --git a/src/cpl_core/dependency_injection/service_provider_abc.py b/src/cpl_core/dependency_injection/service_provider_abc.py index 7d51e751..dd195571 100644 --- a/src/cpl_core/dependency_injection/service_provider_abc.py +++ b/src/cpl_core/dependency_injection/service_provider_abc.py @@ -1,7 +1,7 @@ import functools from abc import abstractmethod, ABC from inspect import Signature, signature -from typing import Type, Optional +from typing import Optional, Type from cpl_core.dependency_injection.scope_abc import ScopeABC from cpl_core.type import T @@ -61,7 +61,7 @@ class ServiceProviderABC(ABC): pass @abstractmethod - def get_service(self, instance_type: T, *args, **kwargs) -> Optional[T]: + def get_service(self, instance_type: Type[T], *args, **kwargs) -> Optional[T]: r"""Returns instance of given type Parameter @@ -76,7 +76,7 @@ class ServiceProviderABC(ABC): pass @abstractmethod - def get_services(self, service_type: T, *args, **kwargs) -> list[Optional[T]]: + def get_services(self, service_type: Type[T], *args, **kwargs) -> list[Optional[T]]: r"""Returns instance of given type Parameter