ets-labs/python-dependency-injector

Broken wiring because of wrong package structure

Closed this issue · 0 comments

dependency-injector==4.45.0

The same symptoms like for #729
except that it does not work only in one place.

...
File "src/dependency_injector/_cwiring.pyx", line 28, in dependency_injector._cwiring._get_sync_patched._patched
...

Solution

In my case I forgot to drop __init__.py in subdir of my package to make it recognized as subpackage.

    wiring_config = containers.WiringConfiguration(
        packages=["myapp"],   # <- make sure all subfolders are packages (myapp/subpackage/__init__.py present)
    )

Adding this issue+solution just in case someone else have this puzzle