Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def __getitem__(self, typeargs: Any) -> object: ...
Generic: _SpecialForm = ...
Protocol: _SpecialForm = ...
Union: _SpecialForm = ...
ClassVar: _SpecialForm = ...

Final = 0
Literal = 0
TypedDict = 0

class TypeVar:
def __init__(self, name, covariant: bool = ..., contravariant: bool = ...) -> None: ...
Expand All @@ -71,6 +76,12 @@ class Match(Generic[AnyStr]): ...
class Sequence(Iterable[_T_co]): ...
class Tuple(Sequence[_T_co]): ...
class NamedTuple(tuple[Any, ...]): ...
class _TypedDict(Mapping[str, object]):
__required_keys__: ClassVar[frozenset[str]]
__optional_keys__: ClassVar[frozenset[str]]
__total__: ClassVar[bool]
__readonly_keys__: ClassVar[frozenset[str]]
__mutable_keys__: ClassVar[frozenset[str]]
def overload(func: _T) -> _T: ...
def type_check_only(func: _T) -> _T: ...
def final(func: _T) -> _T: ...
Expand All @@ -95,6 +106,8 @@ def __ge__(self, __other: tuple[T_co, ...]) -> bool: pass

class dict(Mapping[KT, VT]): ...

class frozenset(Generic[T]): ...

class function: pass
class ellipsis: pass

Expand Down Expand Up @@ -1373,7 +1386,7 @@ def spam(x=Flags4(0)): pass
)
yield Case(
stub="""
from typing_extensions import Final, Literal
from typing import Final, Literal
class BytesEnum(bytes, enum.Enum):
a = b'foo'
FOO: Literal[BytesEnum.a]
Expand Down Expand Up @@ -1915,7 +1928,7 @@ def __init__(self, x): pass
def test_good_literal(self) -> Iterator[Case]:
yield Case(
stub=r"""
from typing_extensions import Literal
from typing import Literal

import enum
class Color(enum.Enum):
Expand Down Expand Up @@ -1947,7 +1960,7 @@ class Color(enum.Enum):

@collect_cases
def test_bad_literal(self) -> Iterator[Case]:
yield Case("from typing_extensions import Literal", "", None) # dummy case
yield Case("from typing import Literal", "", None) # dummy case
yield Case(
stub="INT_FLOAT_MISMATCH: Literal[1]",
runtime="INT_FLOAT_MISMATCH = 1.0",
Expand Down Expand Up @@ -1998,7 +2011,7 @@ def test_special_subtype(self) -> Iterator[Case]:
)
yield Case(
stub="""
from typing_extensions import TypedDict
from typing import TypedDict

class _Options(TypedDict):
a: str
Expand All @@ -2019,8 +2032,8 @@ class _Options(TypedDict):
@collect_cases
def test_runtime_typing_objects(self) -> Iterator[Case]:
yield Case(
stub="from typing_extensions import Protocol, TypedDict",
runtime="from typing_extensions import Protocol, TypedDict",
stub="from typing import Protocol, TypedDict",
runtime="from typing import Protocol, TypedDict",
error=None,
)
yield Case(
Expand Down Expand Up @@ -2385,8 +2398,8 @@ class A2: ...
)
# The same is true for NamedTuples and TypedDicts:
yield Case(
stub="from typing_extensions import NamedTuple, TypedDict",
runtime="from typing_extensions import NamedTuple, TypedDict",
stub="from typing import NamedTuple, TypedDict",
runtime="from typing import NamedTuple, TypedDict",
error=None,
)
yield Case(
Expand Down