|
| 1 | +[case test695TypeAlias] |
| 2 | +type MyInt = int # E: PEP 695 type aliases are not yet supported |
| 3 | + |
| 4 | +def f(x: MyInt) -> MyInt: |
| 5 | + return reveal_type(x) # N: Revealed type is "builtins.int" |
| 6 | + |
| 7 | +type MyList[T] = list[T] # E: PEP 695 type aliases are not yet supported \ |
| 8 | + # E: Name "T" is not defined |
| 9 | + |
| 10 | +def g(x: MyList[int]) -> MyList[int]: # E: Variable "__main__.MyList" is not valid as a type \ |
| 11 | + # N: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases |
| 12 | + return reveal_type(x) # N: Revealed type is "MyList?[builtins.int]" |
| 13 | + |
| 14 | +[case test695Class] |
| 15 | +class MyGen[T]: # E: PEP 695 generics are not yet supported |
| 16 | + def __init__(self, x: T) -> None: # E: Name "T" is not defined |
| 17 | + self.x = x |
| 18 | + |
| 19 | +def f(x: MyGen[int]): # E: "MyGen" expects no type arguments, but 1 given |
| 20 | + reveal_type(x.x) # N: Revealed type is "Any" |
| 21 | + |
| 22 | +[case test695Function] |
| 23 | +def f[T](x: T) -> T: # E: PEP 695 generics are not yet supported \ |
| 24 | + # E: Name "T" is not defined |
| 25 | + return reveal_type(x) # N: Revealed type is "Any" |
| 26 | + |
| 27 | +reveal_type(f(1)) # N: Revealed type is "Any" |
| 28 | + |
| 29 | +async def g[T](x: T) -> T: # E: PEP 695 generics are not yet supported \ |
| 30 | + # E: Name "T" is not defined |
| 31 | + return reveal_type(x) # N: Revealed type is "Any" |
| 32 | + |
| 33 | +reveal_type(g(1)) # E: Value of type "Coroutine[Any, Any, Any]" must be used \ |
| 34 | + # N: Are you missing an await? \ |
| 35 | + # N: Revealed type is "typing.Coroutine[Any, Any, Any]" |
| 36 | + |
| 37 | +[case test695TypeVar] |
| 38 | +from typing import Callable |
| 39 | +type Alias1[T: int] = list[T] # E: PEP 695 type aliases are not yet supported |
| 40 | +type Alias2[**P] = Callable[P, int] # E: PEP 695 type aliases are not yet supported \ |
| 41 | + # E: Value of type "int" is not indexable \ |
| 42 | + # E: Name "P" is not defined |
| 43 | +type Alias3[*Ts] = tuple[*Ts] # E: PEP 695 type aliases are not yet supported \ |
| 44 | + # E: Type expected within [...] \ |
| 45 | + # E: The type "Type[Tuple[Any, ...]]" is not generic and not indexable \ |
| 46 | + # E: Name "Ts" is not defined |
| 47 | + |
| 48 | +class Cls1[T: int]: ... # E: PEP 695 generics are not yet supported |
| 49 | +class Cls2[**P]: ... # E: PEP 695 generics are not yet supported |
| 50 | +class Cls3[*Ts]: ... # E: PEP 695 generics are not yet supported |
| 51 | + |
| 52 | +def func1[T: int](x: T) -> T: ... # E: PEP 695 generics are not yet supported |
| 53 | +def func2[**P](x: Callable[P, int]) -> Callable[P, str]: ... # E: PEP 695 generics are not yet supported \ |
| 54 | + # E: The first argument to Callable must be a list of types, parameter specification, or "..." \ |
| 55 | + # N: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas \ |
| 56 | + # E: Name "P" is not defined |
| 57 | +def func3[*Ts](x: tuple[*Ts]) -> tuple[int, *Ts]: ... # E: PEP 695 generics are not yet supported \ |
| 58 | + # E: Name "Ts" is not defined |
| 59 | +[builtins fixtures/tuple.pyi] |
0 commit comments