-
Notifications
You must be signed in to change notification settings - Fork 42
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
injector._BindingNotYetAvailable: name 'Response' is not defined #66
Comments
I have the same error (Python 3.9 x64, Flask v2.0.1, Flask-Injector v0.12.3) |
My code that worked on older versions of Flask-Injector:
And base REST-resource:
What's wrong with this code? Unfortunately, debugging didn't help me. I found that the error happens in Error:
|
Hi, TL;DR : Issue with Flask > 2 using werkzeug > 2 |
Fixed in 0.13.0, thank you for the report. |
Hello. Is this error fixed? I have the same error raise _BindingNotYetAvailable(e)
injector._BindingNotYetAvailable: name 'Response' is not defined Here is my environment
import flask_restful
from flask import Flask
from flask_injector import FlaskInjector
from injector import inject
class HelloWorld(flask_restful.Resource):
@inject
def __init__(self, *args, int: int, **kwargs):
self._int = int
super().__init__(*args, **kwargs)
def get(self):
return {'int': self._int}
app = Flask(__name__)
api = flask_restful.Api(app)
api.add_resource(HelloWorld, '/')
FlaskInjector(app=app)
app.run() |
Same here. I use
I don't have Werkzeug as a dependency. Any advice? |
We have downgraded Flask version to <2.0.0, it helped. Unfortunately, it was a radical way that may not suit for you. I don’t work with Flask for few months already, so I don’t know if the situation was changed. |
Thanks for the reply. Unfortunately I don't think this will be an option for me. |
I worked around the issue by replacing the dependency injection container. |
Hello,
based on code from this post: #40 injector throws the above error. My code is almost identical, the only difference is flask_restful instead of flask_restplus:
from flask import Flask
from flask_restful import Api, Resource
from flask_injector import FlaskInjector, inject, singleton
app = Flask(name)
app.secret_key = "123"
api = Api(app=app)
class MyConf():
def init(self, val: int):
self.val = val
class MyApi(Resource):
@Inject
def init(self, conf: MyConf, **kwargs): # <- here just added **kwargs to receice the extra passed
api
parameterself.val = conf.val
# Don't know if really needed
super().init(**kwargs)
api.add_resource(MyApi, '/myapi')
def configure(binder):
binder.bind(
MyConf,
to=MyConf(456),
scope=singleton
)
# No need to bind the resource itself
#binder.bind(
# MyApi,
# to=MyApi(myConf)
#)
FlaskInjector(app=app, modules=[configure])
app.run(port=555, debug=True)
Am I doing something wrong here or this is a bug?
My setup:
Flask==2.0.1
Flask-HTTPAuth==4.4.0
Flask-Injector==0.12.3
Flask-JWT==0.3.2
Flask-RESTful==0.3.9
typing-extensions==3.7.4.3
typing-inspect==0.6.0
injector==0.18.4
The text was updated successfully, but these errors were encountered: