I have an issue with relative imports in python. (I really can't do these imports the other way...) Structure of my project is similar to this:
app
├───schemas
└───__init__.py
└───a.py
└───b.py
└───c.py
└───d.py
In file a.py are classes A, ABase. Files b.py, c.py, d.py are analogous.
init.py
from .a import A
from .b import B
from .c import C
from .d import D
The core of the issue is that I have to import classes A and B in both c.py and d.py file but I get "ImportError: cannot import name 'D' from partially initialized module 'app.schemas.d' (most likely due to a circular import) (.\app\schemas_init_.py)"
In files c.py and d.py I have tried already:
- from .a import A \n from .b import B
- from ..schemas import A, B
- from . import A, B
-
- some abominations of the above
For some reason, option 1 works in different projects and I have no idea why now it doesn't...
EDIT: I have forgot about file d.py