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

Incorrect "variable is not accessed" messages #719

Closed
roveo opened this issue Dec 11, 2020 · 4 comments
Closed

Incorrect "variable is not accessed" messages #719

roveo opened this issue Dec 11, 2020 · 4 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@roveo
Copy link

roveo commented Dec 11, 2020

Environment data

  • Language Server version: v2020.12.1
  • OS and version: Mac OS Mojave 10.14.6
  • Python version: 3.7.5 with pyenv

Expected behaviour

When a variable is passed to a function/method that Pylance couldn't introspect (sometimes it's not possible for various reasons), it should not be considered unused.

Actual behaviour

It's grayed out with "variable is not used" message on hover.

Code Snippet / Additional information

I think the best thing I can do here is to show an image of actual code. Stream.from_postgres_increment is a class method, but it's nowhere to be found in Stream class definition: it's actually loaded later on via entry_points mechanism. Pylance can't run introspection on it (and that's totally OK), but the problem is that it also counts all variables passed to this method as unused, while they are obviously used.

image

I don't think there's anything actually "breaking" here, it's more of a logic problem, so I skipped the logs. Will add if you need them.

@erictraut
Copy link
Contributor

Could you provide a self-contained, minimal code sample that reproduces the problem you're seeing? I don't have enough context from the screen shot above to repro the problem.

@roveo
Copy link
Author

roveo commented Dec 11, 2020

EDIT: updated environment info, I'm also using pyenv

I played around a bit and I think it has something to do with how the package was installed.

First, install a package through pip+git:

pip install git+https://github.com/python-streamz/streamz.git

Then, create this file:

from streamz import Stream


def test(x=0):
    y = 1
    Stream.nomethod(x=x, y=y)

x and y should be gray. If I do the same but install from PyPi (pip install streamz), everything works as expected.

@erictraut
Copy link
Contributor

Thanks for the repro instructions. I found and fixed the problem. The fix will be included in the next release.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed triage labels Dec 11, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.12.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020122-11-december-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

3 participants