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

Trying to access an object attribute on the class itself doesn't raise errors #15307

Closed
tusharsadhwani opened this issue May 25, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@tusharsadhwani
Copy link
Contributor

tusharsadhwani commented May 25, 2023

To Reproduce

class SimpleClass:
    def __init__(self) -> None:
        self.a = "test"

print(SimpleClass.a)

Expected Behavior

I was expecting SimpleClass.a to be caught as an error.

Pyright does catch it:

asd.py
  asd.py:5:19 - error: Cannot access member "a" for type "Type[SimpleClass]"
    Member "a" is unknown (reportGeneralTypeIssues)

Actual Behavior

No issues found.

Your Environment

  • Mypy version used: 1.3.0
  • Mypy command-line flags: --strict
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.11
@tusharsadhwani tusharsadhwani added the bug mypy got something wrong label May 25, 2023
@hauntsaninja
Copy link
Collaborator

Duplicate of #240

@hauntsaninja hauntsaninja marked this as a duplicate of #240 May 25, 2023
@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants