impl di in handlers with support custom provider

This commit is contained in:
2025-10-13 01:13:28 +03:00
parent e2753ef904
commit 462a8088e9
12 changed files with 293 additions and 149 deletions
+6 -3
View File
@@ -1,18 +1,19 @@
from collections.abc import Iterator
from typing import Callable
import inspect
from argenta.command import Command
from argenta.response import Response
class CommandHandler:
def __init__(self, handler_as_func: Callable[[Response], None], handled_command: Command):
def __init__(self, handler_as_func: Callable[..., None], handled_command: Command):
"""
Private. Entity of the model linking the handler and the command being processed
:param handler: the handler being called
:param handled_command: the command being processed
"""
self.handler_as_func: Callable[[Response], None] = handler_as_func
self.handler_as_func: Callable[..., None] = handler_as_func
self.handled_command: Command = handled_command
def handling(self, response: Response) -> None:
@@ -30,7 +31,9 @@ class CommandHandlers:
Private. The model that unites all CommandHandler of the routers
:param command_handlers: list of CommandHandlers for register
"""
self.command_handlers: list[CommandHandler] = command_handlers if command_handlers else []
self.command_handlers: list[CommandHandler] = (
command_handlers if command_handlers else []
)
def add_handler(self, command_handler: CommandHandler) -> None:
"""