2023.10 #175
@ -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:
|
||||||
|
@ -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:
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user