From 4e2733f1690f6d85bd7e865e439c89be1a735385 Mon Sep 17 00:00:00 2001 From: RaRhAeu <37556570+RaRhAeu@users.noreply.github.com> Date: Mon, 2 Sep 2024 21:31:05 +0200 Subject: [PATCH] fix: dependencies errors --- eventiq/__about__.py | 2 +- eventiq/dependencies.py | 12 +++--------- eventiq/exceptions.py | 4 ---- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/eventiq/__about__.py b/eventiq/__about__.py index 0b2f79d..c72e379 100644 --- a/eventiq/__about__.py +++ b/eventiq/__about__.py @@ -1 +1 @@ -__version__ = "1.1.3" +__version__ = "1.1.4" diff --git a/eventiq/dependencies.py b/eventiq/dependencies.py index e01381a..94faa2f 100644 --- a/eventiq/dependencies.py +++ b/eventiq/dependencies.py @@ -6,8 +6,6 @@ from typing_extensions import Concatenate, ParamSpec -from .exceptions import DependencyError - if TYPE_CHECKING: from collections.abc import Awaitable @@ -21,9 +19,9 @@ def resolved_func( ) -> Callable[Concatenate[CloudEventType, P], Awaitable[Any]]: sig = signature(func) params = { - k: (v.annotation, v.default) + k: v.annotation for k, v in sig.parameters.items() - if k not in {"message", "args", "kwargs"} + if k != "message" and v.kind not in { Parameter.POSITIONAL_ONLY, @@ -41,13 +39,9 @@ async def wrapped( ) -> Any: state = message.service.state - for k, v in params.items(): - annotation, default = v + for k, annotation in params.items(): if annotation in state: kwargs[k] = state[annotation] - elif k not in kwargs and default is Parameter.empty: - err = f"Missing dependency {k}: {annotation}" - raise DependencyError(err) return await func(message, *args, **kwargs) diff --git a/eventiq/exceptions.py b/eventiq/exceptions.py index 4f8aa62..d48c221 100644 --- a/eventiq/exceptions.py +++ b/eventiq/exceptions.py @@ -13,10 +13,6 @@ class BrokerConnectionError(BrokerError): """Broker connection error.""" -class DependencyError(EventiqError): - """Exception raised when a required dependency could not be resolved.""" - - class EncodeError(EventiqError): """Error encoding message."""