mirror of https://github.com/astral-sh/ruff
make these tests consistent
This commit is contained in:
parent
56b6f26f7b
commit
9b5709f34b
|
|
@ -564,7 +564,7 @@ from typing_extensions import overload, Generic, TypeVar
|
|||
from ty_extensions import generic_context, into_callable
|
||||
|
||||
T = TypeVar("T")
|
||||
U = TypeVar("U")
|
||||
U = TypeVar("U", covariant=True)
|
||||
|
||||
class C(Generic[T]):
|
||||
@overload
|
||||
|
|
@ -614,9 +614,9 @@ reveal_type(generic_context(D))
|
|||
# revealed: ty_extensions.GenericContext[T@D, U@D]
|
||||
reveal_type(generic_context(into_callable(D)))
|
||||
|
||||
reveal_type(D("string")) # revealed: D[str, str]
|
||||
reveal_type(D(1)) # revealed: D[str, int]
|
||||
reveal_type(D(1, "string")) # revealed: D[int, str]
|
||||
reveal_type(D("string")) # revealed: D[str, Literal["string"]]
|
||||
reveal_type(D(1)) # revealed: D[str, Literal[1]]
|
||||
reveal_type(D(1, "string")) # revealed: D[int, Literal["string"]]
|
||||
```
|
||||
|
||||
### Synthesized methods with dataclasses
|
||||
|
|
|
|||
|
|
@ -541,6 +541,10 @@ C[None](b"bytes") # error: [no-matching-overload]
|
|||
C[None](12)
|
||||
|
||||
class D[T, U]:
|
||||
# we need to use the type variable or else the class is bivariant in T, and
|
||||
# specializations become meaningless
|
||||
x: T
|
||||
|
||||
@overload
|
||||
def __init__(self: "D[str, U]", u: U) -> None: ...
|
||||
@overload
|
||||
|
|
@ -554,7 +558,7 @@ reveal_type(generic_context(into_callable(D)))
|
|||
|
||||
reveal_type(D("string")) # revealed: D[str, Literal["string"]]
|
||||
reveal_type(D(1)) # revealed: D[str, Literal[1]]
|
||||
reveal_type(D(1, "string")) # revealed: D[Literal[1], Literal["string"]]
|
||||
reveal_type(D(1, "string")) # revealed: D[int, Literal["string"]]
|
||||
```
|
||||
|
||||
### Synthesized methods with dataclasses
|
||||
|
|
|
|||
Loading…
Reference in New Issue