Skip to content

Commit fcd8402

Browse files
committed
fix test
1 parent 87c8d87 commit fcd8402

File tree

1 file changed

+9
-7
lines changed
  • crates/ty_python_semantic/resources/mdtest/generics/pep695

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```toml
44
[environment]
5-
python-version = "3.12"
5+
python-version = "3.13"
66
```
77

88
[PEP 695] and Python 3.12 introduced new, more ergonomic syntax for type variables.
@@ -752,6 +752,8 @@ def constrained[T: (int, str)](x: T):
752752
A typevar's bounds and constraints cannot be generic, cyclic or otherwise:
753753

754754
```py
755+
from typing import Any
756+
755757
# TODO: error
756758
def f[S, T: list[S]](x: S, y: T) -> S | T:
757759
return x or y
@@ -761,8 +763,8 @@ class C[S, T: list[S]]:
761763
x: S
762764
y: T
763765

764-
reveal_type(C[int, str]().x) # revealed: int
765-
reveal_type(C[int, str]().y) # revealed: str
766+
reveal_type(C[int, list[Any]]().x) # revealed: int
767+
reveal_type(C[int, list[Any]]().y) # revealed: list[Any]
766768

767769
# TODO: error
768770
def g[T: list[T]](x: T) -> T:
@@ -772,7 +774,7 @@ def g[T: list[T]](x: T) -> T:
772774
class D[T: list[T]]:
773775
x: T
774776

775-
reveal_type(D[int]().x) # revealed: int
777+
reveal_type(D[list[Any]]().x) # revealed: list[Any]
776778

777779
# TODO: error
778780
def h[S, T: (list[S], str)](x: S, y: T) -> S | T:
@@ -794,7 +796,7 @@ def i[T: (list[T], str)](x: T) -> T:
794796
class F[T: (list[T], str)]:
795797
x: T
796798

797-
reveal_type(F[int]().x) # revealed: int
799+
reveal_type(F[list[Any]]().x) # revealed: list[Any]
798800
```
799801

800802
However, they are lazily evaluated and can cyclically refer to their own type:
@@ -803,7 +805,7 @@ However, they are lazily evaluated and can cyclically refer to their own type:
803805
class G[T: list[G]]:
804806
x: T
805807

806-
reveal_type(G[list[G]]().x) # revealed: list[G[list[G[Unknown]]]
808+
reveal_type(G[list[G]]().x) # revealed: list[G[Unknown]]
807809
```
808810

809811
### Defaults
@@ -824,7 +826,7 @@ reveal_type(C[int]().y) # revealed: int
824826
class D[T = T]:
825827
x: T
826828

827-
reveal_type(D().x) # revealed: Unknown
829+
reveal_type(D().x) # revealed: T@D
828830
```
829831

830832
[pep 695]: https://peps.python.org/pep-0695/

0 commit comments

Comments
 (0)