PyCharm Editor import assistant uses instead of original source file

Hi experts,

I have a problem with the PyCharm Editor import assistant. I'm developing a library package with many sub-modules in sub-directories. I often include classes from  from low level sub-modules into higher level sub-modules.

The assistant works fine as long I have no top level file. The original sub-modules are found and used for the import statement. But when I add "import ..." statements and an "__all__ = [...]" variable to the top-level, the original source file is no longer used by the assistant, instead the top level is used.

This behavior is fine for consumers of the library, but not for the developer of the library itself. It leads very quickly to "circular import" errors.

Any idea how I can configure PyCharm to use the original source files with import statements when inside a library source file? I have a simple project attached, how it can be found with the ID below. (See src/sample/module_a/ for details).

Kind regards, Andi


Upload id: 2021_08_26_JmoShrQH7yAHEF88 (file:

1 comment
Comment actions Permalink

Hi, thank you for the clear sample project.

Unfortunately, I don't think this is configurable. Taking your example, PyCharm uses the shortest path for auto-import, and from the first glance, I don't see an issue with this.

I think the best course of action is to submit a usability problem to our issue tracker with this project sample, plus the sample of circular import issue resulting from it.


Please sign in to leave a comment.