You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, first of all I would like to thank you for your work.
As for my question, I use inject in my python flask project. There is no problem when working with python, but when I compile with cython, I get the error “init() takes exactly 2 positional arguments (1 given)”. the reason for this error is that inject cannot do its job
inject.py is
import importlib
import inspect
import pkgutil
from flask_injector import FlaskInjector
from injector import Binder, singleton
from src.resources.base_resource import BaseResource
def injects_config(app):
def configure(binder: Binder):
package = importlib.import_module("src.resources")
for _, module_name, _ in pkgutil.walk_packages(package.__path__, package.__name__ + "."):
module = importlib.import_module(module_name)
for name, obj in inspect.getmembers(module):
if inspect.isclass(obj) and issubclass(obj, BaseResource) and obj is not BaseResource:
print(f"Binding {obj} in module {module_name}")
binder.bind(obj, to=obj, scope=singleton)
FlaskInjector(app=app, modules=[configure])
and using like this:
from injector import inject
class XResource(BaseResource):
def __init__(self, x_service: XService):
super().__init__()
self.x_service = x_service
the code works fine in python but when I compile with cython I get the error “init() takes exactly 2 positional arguments (1 given)””
I don't get this error if I remove inject and derive objects manually, like this:
class XResource(BaseResource):
def __init__(self):
super().__init__()
self.x_service = XService()
Hi, first of all I would like to thank you for your work.
As for my question, I use inject in my python flask project. There is no problem when working with python, but when I compile with cython, I get the error “init() takes exactly 2 positional arguments (1 given)”. the reason for this error is that inject cannot do its job
inject.py is
and using like this:
the code works fine in python but when I compile with cython I get the error “init() takes exactly 2 positional arguments (1 given)””
I don't get this error if I remove inject and derive objects manually, like this:
the library versions I use are as follows
I am waiting for the help of those who have experience with the problem. Thank you very much.
The text was updated successfully, but these errors were encountered: