Closed
Description
Minimized from some real code at dropbox exhibiting this failure in a nasty way.
The following code typechecks:
from typing import TypeVar, Generic
T = TypeVar('T')
class A:
def __init__(self, x: T) -> None:
self.x = x
def get(self) -> T:
return self.x
x: int = A('lol').get()
Here, T
is not bound in the class but ends up in the attribute, where it is then matched with the unbound return type variable in get.
(Interestingly, it also works if get
returns a different unbound type variable)
A reveal type reports: Revealed type is 'T`-1'