ty
ty copied to clipboard
Support `type()`'s functional syntax
(First raised on Discord.)
Currently ty doesn't understand type()'s functional syntax very well (playground):
# error: Object of type `type` is not assignable to `type[int]`
U32: type[int] = type('U32', (int,), {})
It understands type(...) returns a new type, but fails to take the bases into account.
Another example:
from unittest import TestCase
tests: list[type[TestCase]] = []
testCaseClass = type("Foo", (TestCase,), {})
# Argument to bound method `append` is incorrect: Expected `type[TestCase]`, found `type`
tests.append(testCaseClass)