2929 Tuple ,
3030 Type ,
3131)
32- from typing import (
33- TypedDict as NativeTypedDict , # type: ignore[not-supported-yet] # pytype
34- )
35- from typing import (
36- TypedDict as RichTypedDict , # type: ignore[not-supported-yet] # pytype
37- )
32+ from typing import TypedDict as NativeTypedDict
33+ from typing import TypedDict as RichTypedDict
3834from typing import TypeVar , Union , cast
3935from unittest import SkipTest , TestCase
4036
@@ -74,9 +70,9 @@ def eval_type(x, y, z):
7470
7571# ParamSpec
7672if sys .version_info >= (3 , 13 ):
77- from typing import ParamSpec # type: ignore[import-error] # pytype
73+ from typing import ParamSpec
7874else :
79- from typing_extensions import ParamSpec # type: ignore[not-supported-yet] # pytype
75+ from typing_extensions import ParamSpec
8076
8177_FAILURE = object ()
8278
@@ -1156,12 +1152,12 @@ def test_typeddict_required_notrequired(self) -> None:
11561152 self .assertIs (typing .Required , typing_extensions .Required ) # type: ignore[16] # pyre
11571153 self .assertIs (typing .NotRequired , typing_extensions .NotRequired ) # type: ignore[16] # pyre
11581154
1159- class TotalMovie (typing_extensions .TypedDict ): # type: ignore[not-supported-yet] # pytype
1155+ class TotalMovie (typing_extensions .TypedDict ):
11601156 title : str
1161- year : typing_extensions .NotRequired [int ] # type: ignore[not-supported-yet] # pytype
1157+ year : typing_extensions .NotRequired [int ]
11621158
11631159 class NontotalMovie (typing_extensions .TypedDict , total = False ):
1164- title : typing_extensions .Required [str ] # type: ignore[not-supported-yet] # pytype
1160+ title : typing_extensions .Required [str ]
11651161 year : int
11661162
11671163 # TotalMovie
@@ -1186,7 +1182,7 @@ def test_typeddict_readonly(self) -> None:
11861182 if sys .version_info >= (3 , 13 ):
11871183 self .assertIs (typing .ReadOnly , typing_extensions .ReadOnly ) # type: ignore[attr-defined, 16] # mypy, pyre
11881184
1189- class Movie (typing_extensions .TypedDict ): # type: ignore[not-supported-yet] # pytype
1185+ class Movie (typing_extensions .TypedDict ):
11901186 title : str
11911187 year : int
11921188
@@ -1519,22 +1515,22 @@ def test_any(self) -> None:
15191515 if sys .version_info >= (3 , 11 ):
15201516
15211517 def test_never (self ) -> None :
1522- self .assertTryCastFailure (Never , "words" ) # type: ignore[wrong-arg-types] # pytype
1523- self .assertTryCastFailure (Never , 1 ) # type: ignore[wrong-arg-types] # pytype
1524- self .assertTryCastFailure (Never , None ) # type: ignore[wrong-arg-types] # pytype
1525- self .assertTryCastFailure (Never , str ) # type: ignore[wrong-arg-types] # pytype
1518+ self .assertTryCastFailure (Never , "words" )
1519+ self .assertTryCastFailure (Never , 1 )
1520+ self .assertTryCastFailure (Never , None )
1521+ self .assertTryCastFailure (Never , str )
15261522
1527- self .assertTryCastFailure (Never , ValueError ) # type: ignore[wrong-arg-types] # pytype
1528- self .assertTryCastFailure (Never , ValueError ()) # type: ignore[wrong-arg-types] # pytype
1523+ self .assertTryCastFailure (Never , ValueError )
1524+ self .assertTryCastFailure (Never , ValueError ())
15291525
15301526 def test_noreturn (self ) -> None :
1531- self .assertTryCastFailure (NoReturn , "words" ) # type: ignore[wrong-arg-types] # pytype
1532- self .assertTryCastFailure (NoReturn , 1 ) # type: ignore[wrong-arg-types] # pytype
1533- self .assertTryCastFailure (NoReturn , None ) # type: ignore[wrong-arg-types] # pytype
1534- self .assertTryCastFailure (NoReturn , str ) # type: ignore[wrong-arg-types] # pytype
1527+ self .assertTryCastFailure (NoReturn , "words" )
1528+ self .assertTryCastFailure (NoReturn , 1 )
1529+ self .assertTryCastFailure (NoReturn , None )
1530+ self .assertTryCastFailure (NoReturn , str )
15351531
1536- self .assertTryCastFailure (NoReturn , ValueError ) # type: ignore[wrong-arg-types] # pytype
1537- self .assertTryCastFailure (NoReturn , ValueError ()) # type: ignore[wrong-arg-types] # pytype
1532+ self .assertTryCastFailure (NoReturn , ValueError )
1533+ self .assertTryCastFailure (NoReturn , ValueError ())
15381534
15391535 # === Forward References ===
15401536
@@ -1885,7 +1881,7 @@ class Point3D(Point2D, total=False): # type: ignore[reportGeneralTypeIssues] #
18851881 if sys .version_info < (3 , 9 ):
18861882
18871883 def test_rejects_python_3_8_typeddict_when_strict_is_true (self ) -> None :
1888- class Point2D (typing .TypedDict ): # type: ignore[not-supported-yet] # pytype
1884+ class Point2D (typing .TypedDict ):
18891885 x : int
18901886 y : int
18911887
@@ -2884,16 +2880,14 @@ def _demands_a_str(value: str) -> str:
28842880 # self._demands_a_never(value) # ensure typechecks
28852881 #
28862882 # @staticmethod
2887- # def _demands_a_never(value: NoReturn) -> NoReturn: # type: ignore[invalid-annotation] # pytype
2883+ # def _demands_a_never(value: NoReturn) -> NoReturn:
28882884 # raise ValueError("expected this code to be unreachable")
28892885
28902886
28912887# ------------------------------------------------------------------------------
28922888# Internal: TestIsTypedDict
28932889
2894- from typing import (
2895- TypedDict as TypingTypedDict , # type: ignore[not-supported-yet] # pytype
2896- )
2890+ from typing import TypedDict as TypingTypedDict
28972891
28982892from trycast import _is_typed_dict
28992893
@@ -2903,9 +2897,7 @@ class TypingPoint(TypingTypedDict):
29032897 y : int
29042898
29052899
2906- from typing_extensions import (
2907- TypedDict as TypingExtensionsTypedDict , # type: ignore[not-supported-yet] # pytype
2908- )
2900+ from typing_extensions import TypedDict as TypingExtensionsTypedDict
29092901
29102902
29112903class TypingExtensionsPoint (TypingExtensionsTypedDict ):
@@ -2950,8 +2942,8 @@ def _tag(tag_name: str) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: # ty
29502942 $ TRYCAST_SKIP_TEST_TAGS=pyright,pyre python -m unittest
29512943 """
29522944
2953- def decorate (f : Callable [_P , _R ]) -> Callable [_P , _R ]: # type: ignore[invalid-annotation] # pytype
2954- def decorated (* args : _P .args , ** kwargs : _P .kwargs ) -> _R : # type: ignore[invalid-annotation] # pytype
2945+ def decorate (f : Callable [_P , _R ]) -> Callable [_P , _R ]:
2946+ def decorated (* args : _P .args , ** kwargs : _P .kwargs ) -> _R :
29552947 if tag_name in os .environ .get ("TRYCAST_SKIP_TEST_TAGS" , "" ).split ("," ):
29562948 raise SkipTest (f"skipping test tagged { tag_name } " )
29572949 return f (* args , ** kwargs )
@@ -3012,23 +3004,5 @@ def test_no_pyre_typechecker_errors_exist(self) -> None:
30123004
30133005 self .fail (f"pyre typechecking failed:\n \n { output_str } " )
30143006
3015- @_tag ("pytype" )
3016- def test_no_pytype_typechecker_errors_exist (self ) -> None :
3017- try :
3018- subprocess .check_output (
3019- ["pytype" , "--keep-going" , "trycast/__init__.py" , "tests.py" ],
3020- env = {"LANG" : "en_US.UTF-8" , "PATH" : os .environ .get ("PATH" , "" )},
3021- stderr = subprocess .STDOUT ,
3022- )
3023- except subprocess .CalledProcessError as e : # pragma: no cover
3024- self .fail (
3025- f'pytype typechecking failed:\n \n { e .output .decode ("utf-8" ).strip ()} '
3026- )
3027- except FileNotFoundError :
3028- if sys .version_info >= (3 , 10 ):
3029- self .skipTest ("Cannot run pytype on Python 3.10+" )
3030- else : # pragma: no cover
3031- raise
3032-
30333007
30343008# ------------------------------------------------------------------------------
0 commit comments