Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp pyright errors #30

Open
sdorof1 opened this issue Oct 20, 2020 · 9 comments
Open

lsp pyright errors #30

sdorof1 opened this issue Oct 20, 2020 · 9 comments

Comments

@sdorof1
Copy link

sdorof1 commented Oct 20, 2020

For the next code (which runs without errors):

import numpy as np
print (np.sign(-1))

I got the error with pyright in emacs:

"sign" is not a known member of module (lsp)

But if I run pyright in the shell, it doesn't report any errors:

$ pyright pyr.py 
No configuration file found.
stubPath /home/sd/pyr/typings is not a valid directory.
Assuming Python platform Linux
Searching for source files
Found 1 source file
0 errors, 0 warnings, 0 infos 
Completed in 0.551sec

So, I get a some mystic error report. This is also in other cases, for example, when work with pandas, when no pyright itself, no vscode doesn't reports any errors.

The value of lsp-pyright-typechecking-mode is basic for all cases.

@seagle0128
Copy link
Collaborator

Is the numpy lib in pyright path? Check lsp-pyright-extra-paths or extraPaths in pyrightconfig.json? See https://github.com/microsoft/pyright/blob/master/docs/configuration.md.

@sdorof1
Copy link
Author

sdorof1 commented Oct 21, 2020

Is the numpy lib in pyright path? Check lsp-pyright-extra-paths or extraPaths in pyrightconfig.json?

I added the next pyrightconfig.json to project folder:

{
  "executionEnvironments": [
    {
      "root": "src"
      "extraPaths": [
         "~/.pyenv/versions/3.8.1/lib/python3.8/site-packages/"
      ]
    }
  ]
}

but without any effect. And I'm confused of need such configuration because numpy is not an some extra but as a rule system lib. It is available on python path and the program works correctly both from shell and emacs. Did I understand you correctly about configuration?

I still can get some correct information from lsp:

Снимок экрана от 2020-10-22 00-41-46

And code completion somehow works but not all functions are displayed:

Снимок экрана от 2020-10-22 01-00-26

So, seems the library is available in some part.

@zeronone
Copy link
Collaborator

zeronone commented Oct 21, 2020 via email

@sdorof1
Copy link
Author

sdorof1 commented Oct 21, 2020

Please pass in the --lib option when running from the shell.

If you mean pyright then it works from shell as expected.

@zeronone
Copy link
Collaborator

zeronone commented Oct 21, 2020 via email

@sdorof1
Copy link
Author

sdorof1 commented Oct 22, 2020

Could you share the output when passing in the --lib option?

Yes, I got it

pyr$ pyright --lib
  4:11 - error: "sign" is not a known member of module (reportGeneralTypeIssues)
1 error, 0 warnings, 0 infos 

Should I just disable useLibraryCodeForTyoes or there is some config that should be done?

@zeronone
Copy link
Collaborator

Disabling useLibraryCodeForTypes will also disable auto-completion for numpy. You might want to filter errors (like unknown member etc) for your project.

@orlandini
Copy link

@zeronone how would one filter errors like that?

@tshu-w
Copy link

tshu-w commented Jun 10, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants