-
- Notifications
You must be signed in to change notification settings - Fork 338
Closed
Labels
Description
Hello! Very useful library - thanks!
I have some trouble with using dependency services in my fastapi application of latest version. (with older versions - no problem)
I make a repository example with example code, that I trying to start.
First example, branch modules
- I use container.wire(modules=....)
https://github.com/Sadbot/di-issue/blob/modules/main.py#L20
And I take an error:
File "/home/sem/www/pythonProject/routes.py", line 25, in test return ORJSONResponse(content=ports.test()) │ └ <dependency_injector.wiring.Provide object at 0x7f4296bcd390> └ <class 'fastapi.responses.ORJSONResponse'> AttributeError: 'Provide' object has no attribute 'test'
Second example, branch packages
- I used container.wire(packages=...)
https://github.com/Sadbot/di-issue/blob/packages/main.py#L20
And I take and error on application startup:
Traceback (most recent call last): File "/home/sem/www/pythonProject/main.py", line 44, in <module> app = create_app() File "/home/sem/www/pythonProject/main.py", line 20, in create_app app.container.wire(packages=[routes]) File "src/dependency_injector/containers.pyx", line 256, in dependency_injector.containers.DynamicContainer.wire File "/home/sem/www/pythonProject/.venv/lib/python3.6/site-packages/dependency_injector/wiring.py", line 330, in wire modules.extend(_fetch_modules(package)) File "/home/sem/www/pythonProject/.venv/lib/python3.6/site-packages/dependency_injector/wiring.py", line 556, in _fetch_modules path=package.__path__, AttributeError: module 'routes' has no attribute '__path__'
What's wrong I done in my code?