1

I have such project structure:

.
├── app.py
├── models
    ├── model1.py
    ├── model2.py
├── connectors.py
    ├── model1_connector.py
    ├── model2_connector.py

I start application using python app.py. Inside of app.py I use

from models.model1 import Model1
from models.model1 import Model1
from connectors.model1_connector import Connector1
from connectors.model2_connector import Connector2

it works perfectly. But in the connectors I use next code:

from models.model1 import Model1

It works on running application, because I start application from . and at start it can recognize all paths correctly. But when I'm working in VSCode its Intellisence craches: when I work in connectors.model1_connector it can't find model folder, because it is in parent folder! I can't use help, can't use Ctrl+click, can't use Tab and so on.

I know I can solve it using `sys.append('../' but I suppose it is not correct - I dont need it for real project to start I need it just for comfort work in VSCode!

What is the best solution here?

Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102
  • Relative imports https://stackoverflow.com/questions/4655526/how-to-accomplish-relative-import-in-python – Tin Nguyen Mar 13 '20 at 09:29
  • What do you mean by "it crashes"? You are also missing `__init__.py` files in both your `model` and `connectors` directories which would probably help. – Brett Cannon Mar 16 '20 at 22:40

0 Answers0