Skip to content

Commit 294daff

Browse files
committed
Mention --enable-incomplete-feature=NewGenericSyntax (#17462)
1 parent 5c33abf commit 294daff

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

mypy/fastparse.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,9 @@ def do_func_def(
954954
else:
955955
self.fail(
956956
ErrorMessage(
957-
"PEP 695 generics are not yet supported", code=codes.VALID_TYPE
957+
"PEP 695 generics are not yet supported. "
958+
"Use --enable-incomplete-feature=NewGenericSyntax for experimental support",
959+
code=codes.VALID_TYPE,
958960
),
959961
n.type_params[0].lineno,
960962
n.type_params[0].col_offset,
@@ -1145,7 +1147,11 @@ def visit_ClassDef(self, n: ast3.ClassDef) -> ClassDef:
11451147
explicit_type_params = self.translate_type_params(n.type_params)
11461148
else:
11471149
self.fail(
1148-
ErrorMessage("PEP 695 generics are not yet supported", code=codes.VALID_TYPE),
1150+
ErrorMessage(
1151+
"PEP 695 generics are not yet supported. "
1152+
"Use --enable-incomplete-feature=NewGenericSyntax for experimental support",
1153+
code=codes.VALID_TYPE,
1154+
),
11491155
n.type_params[0].lineno,
11501156
n.type_params[0].col_offset,
11511157
blocker=False,
@@ -1801,7 +1807,11 @@ def visit_TypeAlias(self, n: ast_TypeAlias) -> TypeAliasStmt | AssignmentStmt:
18011807
return self.set_line(node, n)
18021808
else:
18031809
self.fail(
1804-
ErrorMessage("PEP 695 type aliases are not yet supported", code=codes.VALID_TYPE),
1810+
ErrorMessage(
1811+
"PEP 695 type aliases are not yet supported. "
1812+
"Use --enable-incomplete-feature=NewGenericSyntax for experimental support",
1813+
code=codes.VALID_TYPE,
1814+
),
18051815
n.lineno,
18061816
n.col_offset,
18071817
blocker=False,

test-data/unit/check-python312.test

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[case test695TypeAlias]
2-
type MyInt = int # E: PEP 695 type aliases are not yet supported
2+
type MyInt = int # E: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support
33

44
def f(x: MyInt) -> MyInt:
55
return reveal_type(x) # N: Revealed type is "builtins.int"
66

7-
type MyList[T] = list[T] # E: PEP 695 type aliases are not yet supported \
7+
type MyList[T] = list[T] # E: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
88
# E: Name "T" is not defined
99

1010
def g(x: MyList[int]) -> MyList[int]: # E: Variable "__main__.MyList" is not valid as a type \
@@ -17,21 +17,21 @@ def h(x: MyInt2) -> MyInt2:
1717
return reveal_type(x) # N: Revealed type is "builtins.int"
1818

1919
[case test695Class]
20-
class MyGen[T]: # E: PEP 695 generics are not yet supported
20+
class MyGen[T]: # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support
2121
def __init__(self, x: T) -> None: # E: Name "T" is not defined
2222
self.x = x
2323

2424
def f(x: MyGen[int]): # E: "MyGen" expects no type arguments, but 1 given
2525
reveal_type(x.x) # N: Revealed type is "Any"
2626

2727
[case test695Function]
28-
def f[T](x: T) -> T: # E: PEP 695 generics are not yet supported \
28+
def f[T](x: T) -> T: # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
2929
# E: Name "T" is not defined
3030
return reveal_type(x) # N: Revealed type is "Any"
3131

3232
reveal_type(f(1)) # N: Revealed type is "Any"
3333

34-
async def g[T](x: T) -> T: # E: PEP 695 generics are not yet supported \
34+
async def g[T](x: T) -> T: # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
3535
# E: Name "T" is not defined
3636
return reveal_type(x) # N: Revealed type is "Any"
3737

@@ -41,26 +41,26 @@ reveal_type(g(1)) # E: Value of type "Coroutine[Any, Any, Any]" must be used \
4141

4242
[case test695TypeVar]
4343
from typing import Callable
44-
type Alias1[T: int] = list[T] # E: PEP 695 type aliases are not yet supported \
44+
type Alias1[T: int] = list[T] # E: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
4545
# E: Name "T" is not defined
46-
type Alias2[**P] = Callable[P, int] # E: PEP 695 type aliases are not yet supported \
46+
type Alias2[**P] = Callable[P, int] # E: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
4747
# E: Value of type "int" is not indexable \
4848
# E: Name "P" is not defined
49-
type Alias3[*Ts] = tuple[*Ts] # E: PEP 695 type aliases are not yet supported \
49+
type Alias3[*Ts] = tuple[*Ts] # E: PEP 695 type aliases are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
5050
# E: Name "Ts" is not defined
5151

52-
class Cls1[T: int]: ... # E: PEP 695 generics are not yet supported
53-
class Cls2[**P]: ... # E: PEP 695 generics are not yet supported
54-
class Cls3[*Ts]: ... # E: PEP 695 generics are not yet supported
52+
class Cls1[T: int]: ... # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support
53+
class Cls2[**P]: ... # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support
54+
class Cls3[*Ts]: ... # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support
5555

56-
def func1[T: int](x: T) -> T: ... # E: PEP 695 generics are not yet supported \
56+
def func1[T: int](x: T) -> T: ... # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
5757
# E: Name "T" is not defined
5858

59-
def func2[**P](x: Callable[P, int]) -> Callable[P, str]: ... # E: PEP 695 generics are not yet supported \
59+
def func2[**P](x: Callable[P, int]) -> Callable[P, str]: ... # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
6060
# E: The first argument to Callable must be a list of types, parameter specification, or "..." \
6161
# N: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas \
6262
# E: Name "P" is not defined
63-
def func3[*Ts](x: tuple[*Ts]) -> tuple[int, *Ts]: ... # E: PEP 695 generics are not yet supported \
63+
def func3[*Ts](x: tuple[*Ts]) -> tuple[int, *Ts]: ... # E: PEP 695 generics are not yet supported. Use --enable-incomplete-feature=NewGenericSyntax for experimental support \
6464
# E: Name "Ts" is not defined
6565
[builtins fixtures/tuple.pyi]
6666

0 commit comments

Comments
 (0)