Skip to content

Commit f1a73cf

Browse files
authored
[stubtest] Replace old typing_extensions imports in tests (#18691)
1 parent 87704cd commit f1a73cf

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

mypy/test/teststubtest.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ def __getitem__(self, typeargs: Any) -> object: ...
4848
Generic: _SpecialForm = ...
4949
Protocol: _SpecialForm = ...
5050
Union: _SpecialForm = ...
51+
ClassVar: _SpecialForm = ...
52+
53+
Final = 0
54+
Literal = 0
55+
TypedDict = 0
5156
5257
class TypeVar:
5358
def __init__(self, name, covariant: bool = ..., contravariant: bool = ...) -> None: ...
@@ -71,6 +76,12 @@ class Match(Generic[AnyStr]): ...
7176
class Sequence(Iterable[_T_co]): ...
7277
class Tuple(Sequence[_T_co]): ...
7378
class NamedTuple(tuple[Any, ...]): ...
79+
class _TypedDict(Mapping[str, object]):
80+
__required_keys__: ClassVar[frozenset[str]]
81+
__optional_keys__: ClassVar[frozenset[str]]
82+
__total__: ClassVar[bool]
83+
__readonly_keys__: ClassVar[frozenset[str]]
84+
__mutable_keys__: ClassVar[frozenset[str]]
7485
def overload(func: _T) -> _T: ...
7586
def type_check_only(func: _T) -> _T: ...
7687
def final(func: _T) -> _T: ...
@@ -95,6 +106,8 @@ def __ge__(self, __other: tuple[T_co, ...]) -> bool: pass
95106
96107
class dict(Mapping[KT, VT]): ...
97108
109+
class frozenset(Generic[T]): ...
110+
98111
class function: pass
99112
class ellipsis: pass
100113
@@ -1373,7 +1386,7 @@ def spam(x=Flags4(0)): pass
13731386
)
13741387
yield Case(
13751388
stub="""
1376-
from typing_extensions import Final, Literal
1389+
from typing import Final, Literal
13771390
class BytesEnum(bytes, enum.Enum):
13781391
a = b'foo'
13791392
FOO: Literal[BytesEnum.a]
@@ -1915,7 +1928,7 @@ def __init__(self, x): pass
19151928
def test_good_literal(self) -> Iterator[Case]:
19161929
yield Case(
19171930
stub=r"""
1918-
from typing_extensions import Literal
1931+
from typing import Literal
19191932
19201933
import enum
19211934
class Color(enum.Enum):
@@ -1947,7 +1960,7 @@ class Color(enum.Enum):
19471960

19481961
@collect_cases
19491962
def test_bad_literal(self) -> Iterator[Case]:
1950-
yield Case("from typing_extensions import Literal", "", None) # dummy case
1963+
yield Case("from typing import Literal", "", None) # dummy case
19511964
yield Case(
19521965
stub="INT_FLOAT_MISMATCH: Literal[1]",
19531966
runtime="INT_FLOAT_MISMATCH = 1.0",
@@ -1998,7 +2011,7 @@ def test_special_subtype(self) -> Iterator[Case]:
19982011
)
19992012
yield Case(
20002013
stub="""
2001-
from typing_extensions import TypedDict
2014+
from typing import TypedDict
20022015
20032016
class _Options(TypedDict):
20042017
a: str
@@ -2019,8 +2032,8 @@ class _Options(TypedDict):
20192032
@collect_cases
20202033
def test_runtime_typing_objects(self) -> Iterator[Case]:
20212034
yield Case(
2022-
stub="from typing_extensions import Protocol, TypedDict",
2023-
runtime="from typing_extensions import Protocol, TypedDict",
2035+
stub="from typing import Protocol, TypedDict",
2036+
runtime="from typing import Protocol, TypedDict",
20242037
error=None,
20252038
)
20262039
yield Case(
@@ -2385,8 +2398,8 @@ class A2: ...
23852398
)
23862399
# The same is true for NamedTuples and TypedDicts:
23872400
yield Case(
2388-
stub="from typing_extensions import NamedTuple, TypedDict",
2389-
runtime="from typing_extensions import NamedTuple, TypedDict",
2401+
stub="from typing import NamedTuple, TypedDict",
2402+
runtime="from typing import NamedTuple, TypedDict",
23902403
error=None,
23912404
)
23922405
yield Case(

0 commit comments

Comments
 (0)