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

type of class member can be a free type variable #1903

Closed
rwbarton opened this issue Jul 18, 2016 · 1 comment
Closed

type of class member can be a free type variable #1903

rwbarton opened this issue Jul 18, 2016 · 1 comment
Labels
bug mypy got something wrong priority-1-normal

Comments

@rwbarton
Copy link
Contributor

This doesn't make sense:

from typing import TypeVar

T = TypeVar('T')

class A:
    def __init__(self, x: T) -> None:
        self.x = x

a = A(1)
reveal_type(a.x)  # E: Revealed type is 'T`-1'

I guess we need to check that the types of class attributes don't contain free type variables. (Type variables that are bound by the class declaration, i.e. deriving from Generic[T], are okay of course.)

@ilevkivskyi
Copy link
Member

Tracking this is now moved to #6520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-1-normal
Projects
None yet
Development

No branches or pull requests

3 participants