-
Notifications
You must be signed in to change notification settings - Fork 43
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
Type-hinted list arg causes "TypeError: Injecting partially applied functions is no longer supported." #50
Comments
First of all thanks for a well written report, this is helpful. There's no good solution for this right now because, if my understanding is correct, Connexion only gathers and provides the parameters ( The only short term workaround I can think of is to use https://injector.readthedocs.io/en/latest/api.html#injector.NoInject to mark the parameter(s) as noninjectable. Long-term solutions include:
|
@jstasiak Note that, if I remove the type hint, Flask-Injector ignores the parameter and Connexion successfully injects the value. Similarly, if, instead of a list, I have a scalar API parameter - Thus, I suppose the problem here is that Flask-Injector is incorrectly treating Thank you for pointing out |
If It doesn't matter in principle if it's a scalar parameter or a list or a dictionary. The only difference is Injector crashes when it tries to inject a list that it has no (multi)binding for, while it provides values of other types if only it can instantiate them using parameterless constructors. It doesn't crash by default when trying to provide some types, but it still does inject them before Connexion overrides them. So, to sum up:
That's correct.
That's not correct. Flask-Injector does provide an argument of that type (for diff --git a/injector/__init__.py b/injector/__init__.py
index 9ef06f94c0bd..83a799d0bab9 100644
--- a/injector/__init__.py
+++ b/injector/__init__.py
@@ -1012,6 +1012,7 @@ class Injector:
dependencies.update(kwargs)
try:
+ print('calling %r with %r and %r' % (callable, full_args, dependencies))
return callable(*full_args, **dependencies)
except TypeError as e:
reraise(e, CallError(self_, callable, args, dependencies, e, self._stack)) Then change the type of
even though the response contains the data you expect:
Newer Injector has more helpful error message for the
But the underlying issue remains unchanged. |
How to reproduce:
test_app.py
:test_api.py
:Execute query
GET http://test_app:5000/api/test?list_arg=a&list_arg=b
Expected result:
No error, response
{'list_arg': ['a', 'b']}
Actual result:
Error occurs:
Affected versions:
pip freeze
:Notes:
List[str]
is removed from the argumentlist_arg
, the injection works correctlyThe text was updated successfully, but these errors were encountered: