-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
keyword arguments resolved to None instead of default values when using inject(cast=False)
#115
Comments
@marcodlk thank you for the Issue! I think, this is the bug and we should fix it. Unfortunatelly, I am too busy with FastStream now, but planning to make FastDepends sprint next month |
Sounds good. Not too much rush - thanks to your flexible design, I can just use a |
Ok it will be a bit trickier to patch than I thought. I believe the following line will need to be changed... FastDepends/fast_depends/core/model.py Line 296 in eebb26d
...to something like this: kwargs_ = {arg: solved_kw[arg] for arg in keyword_args if arg in solved_kw} In the current logic, the |
Hi, first of all - thanks for creating fastdepends. Big fan!
Recently, ran into some unexpected behavior which does not appear intended. When
inject(cast=False)
is used, keyword arguments are resolved to None instead of the default value. For example, in the code below,get_hello()
returns "hello, None" instead of "hello, world".When
inject(cast=True)
is used, the default values are used as expected.The source of the issue appears to be the following lines in
core/build.py
:FastDepends/fast_depends/core/build.py
Lines 174 to 177 in eebb26d
In this case,
param.kind
isparam.POSITIONAL_OR_KEYWORD
, which is notparam.KEYWORD_ONLY
, so the param_name gets added to thepositional_args
list instead ofkeyword_args
.Is this intended behavior? It was unexpected to me and feels like an inconsistency.
The text was updated successfully, but these errors were encountered: