Fixed types

This commit is contained in:
Sven Heidemann 2023-10-12 20:55:24 +02:00
parent b3fd122fcd
commit 7881294554
4 changed files with 7 additions and 8 deletions

View File

@ -77,11 +77,11 @@ class ConfigurationABC(ABC):
pass pass
@abstractmethod @abstractmethod
def add_configuration(self, key_type: Type[T], value: any): def add_configuration(self, key_type: T, value: any):
r"""Add configuration object r"""Add configuration object
Parameter: Parameter:
key_type: Union[:class:`str`, :class:`type`] key_type: :class:`cpl_core.type.T`
Type of the value Type of the value
value: any value: any
Object of the value Object of the value
@ -124,11 +124,11 @@ class ConfigurationABC(ABC):
pass pass
@abstractmethod @abstractmethod
def get_configuration(self, search_type: Type[T]) -> Optional[T]: def get_configuration(self, search_type: T) -> Optional[T]:
r"""Returns value from configuration by given type r"""Returns value from configuration by given type
Parameter: Parameter:
search_type: Union[:class:`str`, Type[:class:`cpl_core.configuration.configuration_model_abc.ConfigurationModelABC`]] search_type: :class:`cpl_core.type.T`
Type to search for Type to search for
Returns: Returns:

View File

@ -138,7 +138,7 @@ class ServiceProvider(ServiceProviderABC):
sb = ScopeBuilder(ServiceProvider(descriptors, self._configuration, self._database_context)) sb = ScopeBuilder(ServiceProvider(descriptors, self._configuration, self._database_context))
return sb.build() return sb.build()
def get_service(self, service_type: typing.Type[T], *args, **kwargs) -> Optional[T]: def get_service(self, service_type: T, *args, **kwargs) -> Optional[T]:
result = self._find_service(service_type) result = self._find_service(service_type)
if result is None: if result is None:

View File

@ -61,7 +61,7 @@ class ServiceProviderABC(ABC):
pass pass
@abstractmethod @abstractmethod
def get_service(self, instance_type: Type[T], *args, **kwargs) -> Optional[T]: def get_service(self, instance_type: T, *args, **kwargs) -> Optional[T]:
r"""Returns instance of given type r"""Returns instance of given type
Parameter Parameter
@ -81,7 +81,7 @@ class ServiceProviderABC(ABC):
Parameter Parameter
--------- ---------
instance_type: :class:`cpl_core.type.T` service_type: :class:`cpl_core.type.T`
The type of the searched instance The type of the searched instance
Returns Returns

View File

@ -99,7 +99,6 @@ class DiscordService(DiscordServiceABC, commands.Cog, metaclass=DiscordCogMeta):
try: try:
for command in self._services.get_services(DiscordCommandABC): for command in self._services.get_services(DiscordCommandABC):
self._logger.trace(__name__, f"Register command {type(command).__name__}") self._logger.trace(__name__, f"Register command {type(command).__name__}")
command: Cog = command
if command is None: if command is None:
self._logger.warn(__name__, f"Instance of {type(command).__name__} not found") self._logger.warn(__name__, f"Instance of {type(command).__name__} not found")
continue continue