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

from X import Y as Z highlights Y as undefined with semantic highlighting enabled #376

Closed
syagev opened this issue Sep 16, 2020 · 9 comments
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@syagev
Copy link

syagev commented Sep 16, 2020

Environment data

  • Language Server version: 2020.9.4
  • OS and version: Windows 10 19041
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8

Expected behaviour

Importing dataframe from the popular 3rd party library Dask should not be flagged. The code works when running.

Actual behaviour

from dask import dataframe is flagged with reportUndefinedVariable

image

Logs

Logs
[0916/214947.337:ERROR:registration_protocol_win.cc(103)] CreateFile: The system cannot find the file specified. (0x2)
[Info  - 21:49:47] Pylance language server 2020.9.4 (pyright 9983747f) starting
[Info  - 21:49:47] Server root directory: c:\Users\styagev\.vscode\extensions\ms-python.vscode-pylance-2020.9.4\dist
[Info  - 21:49:48] Background analysis(3) root directory: c:\Users\styagev\.vscode\extensions\ms-python.vscode-pylance-2020.9.4\dist
[Info  - 21:49:48] Background analysis(3) started
[Info  - 21:49:48] Background analysis(4) root directory: c:\Users\styagev\.vscode\extensions\ms-python.vscode-pylance-2020.9.4\dist
[Info  - 21:49:48] Background analysis(4) started
[Error - 21:49:49] stubPath typings is not a valid directory.
[Error - 21:49:51] stubPath typings is not a valid directory.
[Error - 21:49:52] stubPath typings is not a valid directory.
[Error - 21:49:54] stubPath typings is not a valid directory.
[Error - 21:49:56] stubPath typings is not a valid directory.
@judej
Copy link
Contributor

judej commented Sep 16, 2020

@syagev, could you please send the logs from the output window? Also if you can also add a screenshot that would be helpful.

Does dataframe work normally in the rest of file regardless of the message

@judej judej added the waiting for user response Requires more information from user label Sep 16, 2020
@github-actions github-actions bot removed the triage label Sep 16, 2020
@syagev
Copy link
Author

syagev commented Sep 16, 2020

Updated the issue body. Sorry for missing those details.

The import line itself runs well, and dataframe module specifically also.

I should also note I'm pretty sure this is a regression from a previous version. I've been using PyLance on this codebase pretty much since it's first day, and that import was always there so I probably would have noticed it.

@jakebailey
Copy link
Member

To clarify, we're not asking if the code runs, but if you get completion for things inside of dataframe in your code.

I'm guessing yes based on that screenshot, and this is a bug similar to #322. If you set this and reload, does the problem go away?

{
    "[python]": {
        "editor.semanticHighlighting.enabled": false
    }
}

@syagev
Copy link
Author

syagev commented Sep 16, 2020

Ah. Yes, I'm getting completions for that module.

And yes, adding that setting made the problem go away! Thanks ;)

@jakebailey jakebailey added bug Something isn't working and removed waiting for user response Requires more information from user labels Sep 16, 2020
@jakebailey
Copy link
Member

Thanks for checking. This seems like #322, then, though a different AST node is being processed.

@jakebailey jakebailey changed the title from dask import dataframe flagged although exists from X import Y as Z highlights Y as undefined with semantic highlighting enabled Sep 18, 2020
@ChuliangXiao
Copy link

I got the same flagging with pyspark

from pyspark.sql import functions as F

"functions" is not definedPylance (reportUndefinedVariable)

@huguesv huguesv self-assigned this Sep 24, 2020
@huguesv huguesv added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Sep 24, 2020
@huguesv
Copy link
Contributor

huguesv commented Sep 24, 2020

I've implemented a fix, and it will be in the next release of Pylance.

@WayneLambert
Copy link

Yep, just to add to the conversation...

In a Django project, I get the same using this import:

from django.contrib.auth import views as auth_views

Ordinary Import

2020-09-29_14-24-56

Aliased Import

2020-09-29_14-24-29

Hovering over the squiggly line, it says: "views" is not definedPylance (reportUndefinedVariable)

I'll assume by the label that this will be fixed upon next release. This is just in case anyone else comes up against this.

@jakebailey
Copy link
Member

This issue has been fixed in version 2020.9.7, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202097-30-september-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

6 participants