Skip to content

Commit fde4dfc

Browse files
xelanderntCopilot
andauthored
Update that_depends/integrations/faststream.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 6f22f6c commit fde4dfc

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

that_depends/integrations/faststream.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ def __call__(self, msg: Any = None, **kwargs: Any) -> "DIContextMiddleware": #
7474
DIContextMiddleware: A new instance of DIContextMiddleware.
7575
7676
"""
77-
context = kwargs.get("context")
77+
# Explicitly extract and validate 'context'
78+
context = None
79+
if "context" in kwargs:
80+
context = kwargs.pop("context")
81+
if context is not None and not isinstance(context, ContextRepo):
82+
raise TypeError(f"'context' must be of type ContextRepo or None, got {type(context).__name__}")
83+
if kwargs:
84+
raise TypeError(f"Unexpected keyword arguments: {', '.join(kwargs.keys())}")
7885

7986
return DIContextMiddleware(
8087
*self._context_items,

0 commit comments

Comments
 (0)