Prevent PyCharm from accepting directories in the content root as valid imports Follow
I'm not sure exactly why this is, but I have a project with multiple docker images built on top of a base where the environment is specified. E.g.:
Dockerfile – uses base/Dockerfile image as base
application_code/ – imports from my_library...
In my Dockerfile, I install my_library_to_copy in the Docker WORKDIR, so it will be available to import. I also set base/ as a sources root so that PyCharm will look and allow imports from my_library_to_copy/
I noticed, however, that PyCharm will also allow `import base`, which should NOT be legal. But all of the folders in the top level of the project are treated as legal import names. That's bad because the code checker is now fibbing to the developer.
Is there a way I can make `import my_library_to_copy` legal, while `import base` would be correctly identified as a missing import?
In case it's relevant, I've configured the python interpreter for the project to be the one in the base image. That also seems to be working fine (e.g., package versions are displayed as I'd expect).
Please sign in to leave a comment.