ty
ty copied to clipboard
support generic TypedDict
Summary
TypeVars do not seem to be properly handled inside TypedDicts
from typing import TypedDict, reveal_type
class TestDictExample[T](TypedDict):
id: int
name: str
active: bool
bug: T
class Example[T]:
def __init__(self, data: TestDictExample[T]) -> None:
self.attr: TestDictExample[T] = data
def do_something(self) -> T:
value = self.attr["bug"] # ty thinks this is Unknown instead of T
name = self.attr["name"] # ty correctly gets this as str
return value
https://play.ty.dev/fa58789a-4d72-4f76-802d-7dafe74e52b8
Version
ty 0.0.5