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

Class method can‘t recognize class variable. #1064

Closed
stolenzc opened this issue Mar 18, 2021 · 3 comments
Closed

Class method can‘t recognize class variable. #1064

stolenzc opened this issue Mar 18, 2021 · 3 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

@stolenzc
Copy link

Environment data

  • Language Server version: 2021.3.1
  • OS and version: Mac OS 10.15.7
  • Python version (& distribution if applicable, e.g. Anaconda): Python3.8.5

Expected behaviour

example for my code:
image

I can jump to NAME from cls.NAME, I also can jump to NAME from self.NAME, and all NAME will highlight.

Actual behaviour

I can't jump to NAME from cls.NAME, bug I can jump to NAME from self.NAME, and cls.NAME not highlight.

class Hello:

    NAME = 'hello'

    @classmethod
    def get_cls_name(cls):
        return cls.NAME

    def get_self_name(self):
        return self.NAME
@stolenzc
Copy link
Author

I update the pylance to 2021.3.2, this problem also exists.

@erictraut
Copy link
Contributor

Thanks for the bug report. This will be fixed in the next release. It occurs specifically when accessing a class member from the cls parameter in a classmethod.

@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 Mar 18, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.3.3, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202133-24-march-2021

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