11import sys
22import typing
3- from typing import Annotated , Literal , TypeAlias , TypeVar
3+ from typing import Annotated , Literal , NewType , TypeAlias , TypeVar
44
55import typing_extensions
66
@@ -15,6 +15,16 @@ __slots__ = ('foo',) # Y052 Need type annotation for "__slots__"
1515def f (x : "int" ): ... # Y020 Quoted annotations should never be used in stubs
1616def g (x : list ["int" ]): ... # Y020 Quoted annotations should never be used in stubs
1717_T = TypeVar ("_T" , bound = "int" ) # Y020 Quoted annotations should never be used in stubs
18+ _T2 = TypeVar ("_T" , bound = int )
19+ _S = TypeVar ("_S" )
20+ _U = TypeVar ("_U" , "int" , "str" ) # Y020 Quoted annotations should never be used in stubs # Y020 Quoted annotations should never be used in stubs
21+ _U2 = TypeVar ("_U" , int , str )
22+
23+ # This is invalid, but type checkers will flag it, so we don't need to
24+ _V = TypeVar ()
25+
26+ def make_sure_those_typevars_arent_flagged_as_unused (a : _T , b : _T2 , c : _S , d : _U , e : _U2 , f : _V ) -> tuple [_T , _T2 , _S , _U , _U2 , _V ]: ...
27+
1828def h (w : Literal ["a" , "b" ], x : typing .Literal ["c" ], y : typing_extensions .Literal ["d" ], z : _T ) -> _T : ...
1929
2030def i (x : Annotated [int , "lots" , "of" , "strings" ], b : typing .Annotated [str , "more" , "strings" ]) -> None :
@@ -60,3 +70,6 @@ class DocstringAndPass:
6070k = "" # Y052 Need type annotation for "k"
6171el = r"" # Y052 Need type annotation for "el"
6272m = u"" # Y052 Need type annotation for "m"
73+
74+ _N = NewType ("_N" , int )
75+ _NBad = NewType ("_N" , "int" ) # Y020 Quoted annotations should never be used in stubs
0 commit comments