-
Hi, I'm using rope through python-lsp-server and neovim. My question is if it is possible to control how the auto import functionality builds the import statement? My Auto-import works great, but it builds a path like If this is a question for python-lsp-server, I'm happy to ask over there. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
The current implementation of autoimport supports only absolute import. It should be possible to implement a setting to do relative import though this is not currently implemented yet, here is the place where rope generate the import statement. For relative import, python-lsp-server would also need to pass in the filename of the importing module, so that would require a change in both rope and python-lsp-server. cc: @bagel897 |
Beta Was this translation helpful? Give feedback.
-
By setting the Example
Within api.py, importing from views.py would normally be |
Beta Was this translation helpful? Give feedback.
By setting the
python_path
config option to include the subfolder of your project, you can cause the auto-import to stop at the root provided.Example
Within api.py, importing from views.py would normally be
from server.common.views import MyView
. By settingpython_path
to includeserver
, the import becomesfrom common.views import MyView
.