Skip to content

Commit

Permalink
fix: dependencies errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RaRhAeu authored Sep 2, 2024
1 parent 3b69ce1 commit 4e2733f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion eventiq/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.3"
__version__ = "1.1.4"
12 changes: 3 additions & 9 deletions eventiq/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

from typing_extensions import Concatenate, ParamSpec

from .exceptions import DependencyError

if TYPE_CHECKING:
from collections.abc import Awaitable

Expand All @@ -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,
Expand All @@ -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)

Expand Down
4 changes: 0 additions & 4 deletions eventiq/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down

0 comments on commit 4e2733f

Please sign in to comment.