Skip to content

Commit 6dead2e

Browse files
committed
add failing test cases
1 parent faae72b commit 6dead2e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

crates/ty_python_semantic/resources/mdtest/generics/legacy/classes.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ wrong_innards: C[int] = C("five", 1)
466466
from typing_extensions import overload, Generic, TypeVar
467467

468468
T = TypeVar("T")
469+
U = TypeVar("U")
469470

470471
class C(Generic[T]):
471472
@overload
@@ -497,6 +498,17 @@ C[int](12)
497498
C[None]("string") # error: [no-matching-overload]
498499
C[None](b"bytes") # error: [no-matching-overload]
499500
C[None](12)
501+
502+
class D(Generic[T, U]):
503+
@overload
504+
def __init__(self: "D[str, U]", u: U) -> None: ...
505+
@overload
506+
def __init__(self, t: T, u: U) -> None: ...
507+
def __init__(self, *args) -> None: ...
508+
509+
reveal_type(D("string")) # revealed: D[str, str]
510+
reveal_type(D(1)) # revealed: D[str, int]
511+
reveal_type(D(1, "string")) # revealed: D[int, str]
500512
```
501513

502514
### Synthesized methods with dataclasses

crates/ty_python_semantic/resources/mdtest/generics/pep695/classes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,17 @@ C[int](12)
436436
C[None]("string") # error: [no-matching-overload]
437437
C[None](b"bytes") # error: [no-matching-overload]
438438
C[None](12)
439+
440+
class D[T, U]:
441+
@overload
442+
def __init__(self: "D[str, U]", u: U) -> None: ...
443+
@overload
444+
def __init__(self, t: T, u: U) -> None: ...
445+
def __init__(self, *args) -> None: ...
446+
447+
reveal_type(D("string")) # revealed: D[str, str]
448+
reveal_type(D(1)) # revealed: D[str, int]
449+
reveal_type(D(1, "string")) # revealed: D[int, str]
439450
```
440451

441452
### Synthesized methods with dataclasses

0 commit comments

Comments
 (0)