Closed marcodlk closed 1 month ago
@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 wrap_model
function to make necessary patch in the meantime :)
Ok it will be a bit trickier to patch than I thought. I believe the following line will need to be changed...
...to something like this:
kwargs_ = {arg: solved_kw[arg] for arg in keyword_args if arg in solved_kw}
In the current logic, the solved_kw
does not contain the value, so the params in keyword_args
get value set to None and the None is injected as the keyword arg in the function call, overwriting the default.
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
: https://github.com/Lancetnik/FastDepends/blob/eebb26d597172114fb63c666b1bf2d6f193371ce/fast_depends/core/build.py#L174-L177In 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.