palantir / python-language-server

An implementation of the Language Server Protocol for Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyls not working with star '*' imports

atticusmatticus opened this issue · comments

I am using Neovim 0.5.0-dev+nightly with pyls which works well and quickly for most packages like numpy for example. However when used with the fastai library the LSP just returns:

Diagnostics:
1. 'from fastai.vision.all import *' used; unable to detect undefined names

The fastai library is designed to be imported this way so changing this line isn't really a viable option.

To reproduce my issue you can install fastai via miniconda3:
conda install -c fastai -c pytorch fastai
and then install python-language-server:
conda install python-language-server

Then open a file in neovim with the conda-env enabled and pyls enabled, here is a short example file:

from fastai.vision.all import *

path = untar_data(URLs.PETS)/'images'

def is_cat(x): return x[0].isupper()
dls = ImageDataLoaders.from_name_func(
        path, get_image_files(path), valid_pct=0.2, seed=42,
        label_func=is_cat, item_tfms=Resize(224))

learn = cnn_learner(dls, resnet34, metrics = error_rate)

all of these functions show as having warnings, for example for the path= line:
'untar_data' may be undefined, or defined from star imports: fastai.vision.all

And the hover help for example doesn't work for these functions. Is there something that can be done to make wildcard imports like this work correctly with the language server?

If there is anymore information I can give you please let me know. Thanks