@@ -4415,3 +4415,96 @@ class Test(Whatever, a=1, b='b', c=True, d=1.5, e=None, f=1j, g=b'123'): ...
44154415class Test(Whatever, keyword=SomeName * 2, attr=SomeName.attr): ...
44164416[out]
44174417class Test(Whatever, keyword=SomeName * 2, attr=SomeName.attr): ...
4418+
4419+ [case testPEP695GenericClass]
4420+ # flags: --python-version=3.12
4421+
4422+ class C[T]: ...
4423+ class C1[T1](int): ...
4424+ class C2[T2: int]: ...
4425+ class C3[T3: str | bytes]: ...
4426+ class C4[T4: (str, bytes)]: ...
4427+
4428+ class Outer:
4429+ class Inner[T]: ...
4430+
4431+ [out]
4432+ class C[T]: ...
4433+ class C1[T1](int): ...
4434+ class C2[T2: int]: ...
4435+ class C3[T3: str | bytes]: ...
4436+ class C4[T4: (str, bytes)]: ...
4437+
4438+ class Outer:
4439+ class Inner[T]: ...
4440+
4441+ [case testPEP695GenericFunction]
4442+ # flags: --python-version=3.12
4443+
4444+ def f1[T1](): ...
4445+ def f2[T2: int](): ...
4446+ def f3[T3: str | bytes](): ...
4447+ def f4[T4: (str, bytes)](): ...
4448+
4449+ class C:
4450+ def m[T](self, x: T) -> T: ...
4451+
4452+ [out]
4453+ def f1[T1]() -> None: ...
4454+ def f2[T2: int]() -> None: ...
4455+ def f3[T3: str | bytes]() -> None: ...
4456+ def f4[T4: (str, bytes)]() -> None: ...
4457+
4458+ class C:
4459+ def m[T](self, x: T) -> T: ...
4460+
4461+ [case testPEP695TypeAlias]
4462+ # flags: --python-version=3.12
4463+
4464+ type Alias = int | str
4465+ type Alias1[T1] = list[T1] | set[T1]
4466+ type Alias2[T2: int] = list[T2] | set[T2]
4467+ type Alias3[T3: str | bytes] = list[T3] | set[T3]
4468+ type Alias4[T4: (str, bytes)] = list[T4] | set[T4]
4469+
4470+ class C:
4471+ type IndentedAlias[T] = list[T]
4472+
4473+ [out]
4474+ type Alias = int | str
4475+ type Alias1[T1] = list[T1] | set[T1]
4476+ type Alias2[T2: int] = list[T2] | set[T2]
4477+ type Alias3[T3: str | bytes] = list[T3] | set[T3]
4478+ type Alias4[T4: (str, bytes)] = list[T4] | set[T4]
4479+ class C:
4480+ type IndentedAlias[T] = list[T]
4481+
4482+ [case testPEP695Syntax_semanal]
4483+ # flags: --python-version=3.12
4484+
4485+ class C[T]: ...
4486+ def f[S](): ...
4487+ type A[R] = list[R]
4488+
4489+ [out]
4490+ class C[T]: ...
4491+
4492+ def f[S]() -> None: ...
4493+ type A[R] = list[R]
4494+
4495+ [case testPEP696Syntax]
4496+ # flags: --python-version=3.13
4497+
4498+ type Alias1[T1 = int] = list[T1] | set[T1]
4499+ type Alias2[T2: int | float = int] = list[T2] | set[T2]
4500+ class C3[T3 = int]: ...
4501+ class C4[T4: int | float = int](list[T4]): ...
4502+ def f5[T5 = int](): ...
4503+
4504+ [out]
4505+ type Alias1[T1 = int] = list[T1] | set[T1]
4506+ type Alias2[T2: int | float = int] = list[T2] | set[T2]
4507+ class C3[T3 = int]: ...
4508+ class C4[T4: int | float = int](list[T4]): ...
4509+
4510+ def f5[T5 = int]() -> None: ...
0 commit comments