[ty] Pull types on synthesized Python files created by mdtest (#18539)

This commit is contained in:
Alex Waygood
2025-06-12 10:32:17 +01:00
committed by GitHub
parent e6fe2af292
commit 324e5cbc19
14 changed files with 361 additions and 191 deletions

View File

@@ -139,6 +139,8 @@ x: int = MagicMock()
## Invalid
<!-- pull-types:skip -->
`Any` cannot be parameterized:
```py

View File

@@ -58,6 +58,8 @@ def _(c: Callable[[int, 42, str, False], None]):
### Missing return type
<!-- pull-types:skip -->
Using a parameter list:
```py

View File

@@ -14,6 +14,8 @@ directly.
### Negation
<!-- pull-types:skip -->
```py
from typing import Literal
from ty_extensions import Not, static_assert
@@ -371,6 +373,8 @@ static_assert(not is_single_valued(Literal["a"] | Literal["b"]))
## `TypeOf`
<!-- pull-types:skip -->
We use `TypeOf` to get the inferred type of an expression. This is useful when we want to refer to
it in a type expression. For example, if we want to make sure that the class literal type `str` is a
subtype of `type[str]`, we can not use `is_subtype_of(str, type[str])`, as that would test if the
@@ -412,6 +416,8 @@ def f(x: TypeOf) -> None:
## `CallableTypeOf`
<!-- pull-types:skip -->
The `CallableTypeOf` special form can be used to extract the `Callable` structural type inhabited by
a given callable object. This can be used to get the externally visibly signature of the object,
which can then be used to test various type properties.

View File

@@ -84,6 +84,8 @@ d.a = 2
## Too many arguments
<!-- pull-types:skip -->
```py
from typing import ClassVar

View File

@@ -45,6 +45,8 @@ reveal_type(FINAL_E) # revealed: int
## Too many arguments
<!-- pull-types:skip -->
```py
from typing import Final