sublimelsp / LSP-pyright

Python support for Sublime's LSP plugin provided through microsoft/pyright.
MIT License
131 stars 13 forks source link

How to get import auto suggestion from __init__.py files? #337

Open rocchidavide opened 5 months ago

rocchidavide commented 5 months ago

My django project structure is something like that:

django-project/
    .venv/
     manage.py
     project/
       settings.py
       bar/
         __init__.py
         models/
           __init__.py
           company.py
         api/
           __init__.py
           companies/
             views.py
             serializers.py

In models/__init__.py there are imports:

from .company import Company

Same way for api package.

The problem I need that LSP pyright suggests me imports from inits, for example:

from bar.models import Company

instead of

from bar.models.company import Company

My .sublime-project file contains these settings:

{
    "settings":
    {
        "LSP": {
            "LSP-pyright": {
                "settings": {
                    "python.pythonPath": "$folder/.venv/bin/python3"
                }
            }
        }
    }
}

Is it possible? Thank you!

jfcherng commented 5 months ago

It seems to just import from where it's defined... I actually recommend asking in https://github.com/microsoft/pyright since we don't implement pyright itself.