Content entries should not intersect, but my python paths do...
Answered
So I'm working in a codebase where many of the file import not just from the top of the hierarchy, but also from a few places under it. For example with the following file structure:
Dir1
file1.py
Dir2
file2.py
Existing code might do this:
import file1
import Dir2.file2 as file2
To get the IDE and MayaCharm to be happy, I would have to specify both Dir1 and Dir1/Dir2 as content roots. But they interersect, so I can't. If I just use Dir1, MayaCharm marks all paths starting with Dir2 with squiggly error lines, and browsing for symbols doesn't work well.
I can't modify all imports in everyone's code to start at a common root.
So, what can I do?
Thanks!
Please sign in to leave a comment.
Hi Sdas, try marking Dir1 (and any other directories needed to be added to PYTHONPATH) as Source Root by right-clicking in the project root -> Mark Directory as -> Source Root. This way PyCharm should start to resolve imports like import Dir2.file2 as file2.
That worked, thank you Pavel!
Unfortunately, this doesn't work if you have multiple content roots.
If you'd like, please submit a bug report to https://youtrack.jetbrains.com with a minimal project sample and a screenshot of your project structure settings, and we'll take a look.