Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,44 @@ type YNested = (1 + (yield from [])) # E: Yield expression cannot be used within
type ZNested = (1 + (a := 1)) # E: Named expression cannot be used within a type alias
type KNested = (1 + (await 1)) # E: Await expression cannot be used within a type alias

[case testWalrusRebindsNamesLoadedInComprehensionTargets]
# Newly legal in https://github.com/python/cpython/pull/100581
from typing import Any

def f(c: Any, d: Any, e: Any, f: Any, g: Any, h: Any, j: Any) -> None:
((c := 1) for a, (*b, c[d+e::f(g)], h.i) in j)
[(c := 1) for a, (*b, c[d+e::f(g)], h.i) in j]
{(c := 1) for a, (*b, c[d+e::f(g)], h.i) in j}

((d := 1) for a, (*b, c[d+e::f(g)], h.i) in j)
[(d := 1) for a, (*b, c[d+e::f(g)], h.i) in j]
{(d := 1) for a, (*b, c[d+e::f(g)], h.i) in j}

((e := 1) for a, (*b, c[d+e::f(g)], h.i) in j)
[(e := 1) for a, (*b, c[d+e::f(g)], h.i) in j]
{(e := 1) for a, (*b, c[d+e::f(g)], h.i) in j}

((f := 1) for a, (*b, c[d+e::f(g)], h.i) in j)
[(f := 1) for a, (*b, c[d+e::f(g)], h.i) in j]
{(f := 1) for a, (*b, c[d+e::f(g)], h.i) in j}

((g := 1) for a, (*b, c[d+e::f(g)], h.i) in j)
[(g := 1) for a, (*b, c[d+e::f(g)], h.i) in j]
{(g := 1) for a, (*b, c[d+e::f(g)], h.i) in j}

((h := 1) for a, (*b, c[d+e::f(g)], h.i) in j)
[(h := 1) for a, (*b, c[d+e::f(g)], h.i) in j]
{(h := 1) for a, (*b, c[d+e::f(g)], h.i) in j}

((i := 1) for a, (*b, c[d+e::f(g)], h.i) in j)
[(i := 1) for a, (*b, c[d+e::f(g)], h.i) in j]
{(i := 1) for a, (*b, c[d+e::f(g)], h.i) in j}

((j := 1) for a, (*b, c[d+e::f(g)], h.i) in j)
[(j := 1) for a, (*b, c[d+e::f(g)], h.i) in j]
{(j := 1) for a, (*b, c[d+e::f(g)], h.i) in j}
[builtins fixtures/primitives.pyi]

[case testPEP695TypeAliasAndAnnotated]
from typing_extensions import Annotated, Annotated as _Annotated
import typing_extensions as t
Expand Down
2 changes: 2 additions & 0 deletions test-data/unit/fixtures/primitives.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@ class range(Sequence[int]):
def isinstance(x: object, t: Union[type, Tuple]) -> bool: pass

class BaseException: pass

class slice: pass
Loading