diff --git a/mypy/test/teststubtest.py b/mypy/test/teststubtest.py index 58602be3a624..a2e9668a9ac4 100644 --- a/mypy/test/teststubtest.py +++ b/mypy/test/teststubtest.py @@ -72,7 +72,6 @@ class Tuple(Sequence[_T_co]): ... class NamedTuple(tuple[Any, ...]): ... def overload(func: _T) -> _T: ... def type_check_only(func: _T) -> _T: ... -def deprecated(__msg: str) -> Callable[[_T], _T]: ... def final(func: _T) -> _T: ... """ @@ -635,7 +634,8 @@ def f5(__b: str) -> str: ... ) yield Case( stub=""" - from typing import deprecated, final + from typing import final + from typing_extensions import deprecated class Foo: @overload @final diff --git a/mypy/types.py b/mypy/types.py index e7738bd7d088..d19766c1de34 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -123,7 +123,7 @@ ANNOTATED_TYPE_NAMES: Final = ("typing.Annotated", "typing_extensions.Annotated") # Supported @deprecated type names -DEPRECATED_TYPE_NAMES: Final = ("typing.deprecated", "typing_extensions.deprecated") +DEPRECATED_TYPE_NAMES: Final = ("warnings.deprecated", "typing_extensions.deprecated") # We use this constant in various places when checking `tuple` subtyping: TUPLE_LIKE_INSTANCE_NAMES: Final = ( diff --git a/test-data/unit/lib-stub/typing_extensions.pyi b/test-data/unit/lib-stub/typing_extensions.pyi index 216005e3cf83..c88aa5c815c5 100644 --- a/test-data/unit/lib-stub/typing_extensions.pyi +++ b/test-data/unit/lib-stub/typing_extensions.pyi @@ -1,5 +1,5 @@ import typing -from typing import Any, Mapping, Iterable, Iterator, NoReturn as NoReturn, Dict, Tuple, Type +from typing import Any, Callable, Mapping, Iterable, Iterator, NoReturn as NoReturn, Dict, Tuple, Type from typing import TYPE_CHECKING as TYPE_CHECKING from typing import NewType as NewType, overload as overload @@ -75,5 +75,6 @@ def dataclass_transform( ) -> Callable[[T], T]: ... def override(__arg: _T) -> _T: ... +def deprecated(__msg: str) -> Callable[[_T], _T]: ... _FutureFeatureFixture = 0