
June 2, 2021
1:15 p.m.
Say parse is a method that adds attributes from the class's annotations. ```python class Foo: bar: int def parse(self, data: bytes) -> Foo: for name, type in self.__annotations__.items(): value = read_chunk(data) assert isinstance(value, type) setattr(self, name, value) return self class SubFoo: baz: str ``` If I then call reveal_type(SubFoo().parse(...)) would say that this is of type Foo, but if I use TypeVars on the self parameter it would be correct and say that the type is of SubFoo.