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

Non existing member does not get reported when using +=, -=,... operators #1858

Closed
meollab opened this issue Sep 22, 2021 · 3 comments
Closed
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@meollab
Copy link

meollab commented Sep 22, 2021

Environment data

  • Language Server version: 2021.9.2
  • OS and version: Linux x64
  • Python version (and distribution if applicable, e.g. Anaconda): Python 3.7.5 (64bit)
  • python.analysis.indexing: undefined
  • python.analysis.typeCheckingMode: basic

Expected behaviour

class ExampleA:
    def blah(self) -> None:
        self.does_not_exist_a += 3

should report does_not_exist_a as not existing

Actual behaviour

Pyright does not report any error or warning

Code Snippet / Additional information

  • The problem with does_not_exist_a is reported by both mypy and pylint
    • mypy: error: "ExampleA" has no attribute "does_not_exist_a"
    • pylint: E1101: Instance of 'ExampleA' has no 'does_not_exist_a' member (no-member)
  • Pyright correctly reports Cannot access member "does_not_exist_b" for type "ExampleB"  Member "does_not_exist_b" is unknown here
class ExampleB:
    def blah(self) -> None:
        print(self.does_not_exist_b)
@erictraut
Copy link
Contributor

Thanks for the bug report. I agree that this is a false negative case that a static type checker can detect. In particular, if the only assignments to an instance variable are through augmented assignment expressions, it should be flagged as an error.

@erictraut erictraut added enhancement New feature or request and removed triage labels Sep 22, 2021
@erictraut
Copy link
Contributor

This will be addressed in the next release.

@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Sep 22, 2021
@jakebailey
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 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