davidhalter / jedi

Awesome autocompletion, static analysis and refactoring library for python
http://jedi.readthedocs.io
Other
5.78k stars 508 forks source link

Question: making jedi understand dynamically managed imports #2011

Closed MichalHe closed 3 months ago

MichalHe commented 3 months ago

Hi, I am working on a project that uses a custom module finder and loader to facilitate separation guarantees between project's submodules. To illustrate, we have a following module structure

actors/
    |- myactorA/
         |- actor.py
         |- libraries/
             |- libraryA.py
    |- myactorB/
         |- actor.py
         |- libraries/
             |- library.py

The goal is to make actors unaware of other actors. Actor's code looks in the following fashion:

# actors/myactorA/actor.py
from project.actor.libraries import libraryA

The framework resolves the import to libraryA.py.

Question:

Thank you very much.

davidhalter commented 3 months ago

This is not supported at the moment and there are no plans to. Why is the special import system a requirement? Why don't you work with the other tools that Python gives you?

There might be ways to work around the issue if you use Interpreter mode and set the correct import logic there (Jedi mostly uses importlib).

I'm closing, because there won't be an implementation here, but I'm happy to keep responding here.