[ty] Support `typing.TypeForm` (#25334)
## Summary
`TypeForm[T]` describes a value that is a valid type expression
representing a type assignable to `T`. Unlike `type[T]`, it can describe
forms such as parameterized generics and unions, not only runtime class
objects:
```python
from typing import assert_type
from typing_extensions import TypeForm
def construct[T](form: TypeForm[T]) -> T:
raise NotImplementedError
assert_type(construct(int), int)
assert_type(construct(list[int]), list[int])
assert_type(construct(int | str), int | str)
```
This PR adds support for `TypeForm[T]`, bringing us into alignment with
the conformance suite.
For bare `type`, we treat it as a runtime class value, but one that
doesn't promise a specific represented type, so it's valid for broad
TypeForm destinations, but not narrow ones:
```python
def use_bare_runtime_class(runtime_type: type) -> None:
any_form: TypeForm[Any] = runtime_type
object_form: TypeForm[object] = runtime_type
string_form: TypeForm[str] = runtime_type # error
```
Closes https://github.com/astral-sh/ty/issues/2668. C
Charlie Marsh committed
3cb09eba689ebb49e799131092121928cc789c18
Parent: c8cd59f
Committed by GitHub <noreply@github.com>
on 5/27/2026, 3:15:14 PM