Skip to content

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

Closed

Description

@rwbarton

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.)

Activity

  1. added this to the milestone on Jul 21, 2016
  2. removed this from the milestone on Mar 29, 2017
  3. ilevkivskyi commented on Nov 7, 2019

    @ilevkivskyi
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions