0

Consider I have a project with the following structure:

A/a1.py
A/B/b1.py
A/B/C/c1.py
D/E/F/f1.py
main.py

I need to do the following imports

main.py needs to import a1
a1 needs to import b1
b1 needs to import c1
c1 needs to import f1

I am having trouble understanding how to do this correctly:

My current try is:

main.py -> import A.a1
b1.py -> import A.a1
c1.py -> import A.B.b1
c1.py -> import D.E.F.f1

The program is called from the main.py. This works, but the IDE is totally confused.

What is the correct way to do this?

Some background to the question

The background for the structure is. I have a main.py which is an python-dash-app and then I have one folder for backend and frontend and the frontend has a folder for the tabs and a tab needs to access code from the backend.
aushdk
  • 1
  • 2
  • In these types of questions, it would help to mention *which* IDE since the resolution will vary (VSCode, PyCharm, etc) – Cory Kramer Dec 13 '22 at 15:51
  • PyCharm but I would like a solution, that works also for vscode. – aushdk Dec 13 '22 at 15:55
  • Can you maybe share your code? It's difficult to figure out what you want to do. – Nineteendo Dec 13 '22 at 16:05
  • I want to the set up the structure and do the imports as written and still the IDE should be able to provide auto hints about the content of the files. – aushdk Dec 13 '22 at 16:13

1 Answers1

0

The solution is ok. You only need to add the directory as ROOT SOURCE in Pycharm by clicking right-click Mark Directory as SOURCE ROOT. Now Pycharm is not confused anymore and autocomplete works.

aushdk
  • 1
  • 2