mirror of
https://github.com/astral-sh/ruff
synced 2026-01-07 22:54:28 -05:00
[ty] Pull types on synthesized Python files created by mdtest (#18539)
This commit is contained in:
@@ -139,6 +139,8 @@ x: int = MagicMock()
|
||||
|
||||
## Invalid
|
||||
|
||||
<!-- pull-types:skip -->
|
||||
|
||||
`Any` cannot be parameterized:
|
||||
|
||||
```py
|
||||
|
||||
@@ -58,6 +58,8 @@ def _(c: Callable[[int, 42, str, False], None]):
|
||||
|
||||
### Missing return type
|
||||
|
||||
<!-- pull-types:skip -->
|
||||
|
||||
Using a parameter list:
|
||||
|
||||
```py
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -84,6 +84,8 @@ d.a = 2
|
||||
|
||||
## Too many arguments
|
||||
|
||||
<!-- pull-types:skip -->
|
||||
|
||||
```py
|
||||
from typing import ClassVar
|
||||
|
||||
|
||||
@@ -45,6 +45,8 @@ reveal_type(FINAL_E) # revealed: int
|
||||
|
||||
## Too many arguments
|
||||
|
||||
<!-- pull-types:skip -->
|
||||
|
||||
```py
|
||||
from typing import Final
|
||||
|
||||
|
||||
Reference in New Issue
Block a user