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

mypy infers nonexistent class attribute from instance attribute #7524

Closed
untitaker opened this issue Sep 17, 2019 · 1 comment
Closed

mypy infers nonexistent class attribute from instance attribute #7524

untitaker opened this issue Sep 17, 2019 · 1 comment

Comments

@untitaker
Copy link

The following typechecks correctly with mypy 0.720, but blows up at runtime:

from typing import Type

class A(object):
    both = 42  # type: int

    def __init__(self):
        # type: () -> None
        self.instance_only = 42  # type: int


a = A()  # type: A
b = A  # type: Type[A]

print(a.both)
print(b.both)

print(a.instance_only)
print(b.instance_only)  # AttributeError
@JukkaL
Copy link
Collaborator

JukkaL commented Sep 20, 2019

Closing as duplicate of #1097.

@JukkaL JukkaL closed this as completed Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants