Skip to content

Add 3.14 Deprecations #14289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
87447ec
Add 3.14 deprecations
max-muoto Jun 16, 2025
2e34041
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 16, 2025
c52f786
Fix
max-muoto Jun 16, 2025
7b92886
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 16, 2025
5c5315a
Fixes
max-muoto Jun 16, 2025
74badea
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 16, 2025
0f14bad
Revert
max-muoto Jun 16, 2025
da6d451
Fix
max-muoto Jun 16, 2025
6661c35
Revert
max-muoto Jun 17, 2025
1e2e617
Fix
max-muoto Jun 17, 2025
ed65903
Fix
max-muoto Jun 17, 2025
2bffae4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 17, 2025
647bb88
Address comments
max-muoto Jun 18, 2025
d40fc6c
Fix
max-muoto Jun 18, 2025
83efd5d
revert
max-muoto Jun 18, 2025
90c97d4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2025
7eccbac
Add override
max-muoto Jun 18, 2025
4f5c981
Fix tests
max-muoto Jun 18, 2025
28a1743
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2025
3de835b
Tweaks
max-muoto Jun 18, 2025
8c44563
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2025
94c49d6
3.13
max-muoto Jun 18, 2025
7d0fb15
Merge branch 'main' into add-3.14-deprecations
srittau Jul 7, 2025
8f97cb9
Merge branch 'main' of https://github.com/max-muoto/typeshed into add…
max-muoto Jul 12, 2025
5c89ea7
Tweak
max-muoto Jul 12, 2025
3034a9d
Add ignore
max-muoto Jul 12, 2025
4fbdb04
Tweak tests
max-muoto Jul 12, 2025
3e6d012
Fix
max-muoto Jul 13, 2025
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
32 changes: 27 additions & 5 deletions stdlib/@tests/test_cases/asyncio/check_coroutines.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,47 @@
from __future__ import annotations

import inspect
from asyncio import iscoroutinefunction
from collections.abc import Awaitable, Callable, Coroutine
from types import CoroutineType
from typing import Any
from typing_extensions import assert_type


def test_iscoroutinefunction(
def test_iscoroutinefunction_asyncio(
x: Callable[[str, int], Coroutine[str, int, bytes]],
y: Callable[[str, int], Awaitable[bytes]],
z: Callable[[str, int], str | Awaitable[bytes]],
xx: object,
) -> None:
if iscoroutinefunction(x):
# Type ignores are neeeded due to deprecation of iscoroutinefunction in 3.14
if iscoroutinefunction(x): # type: ignore
assert_type(x, Callable[[str, int], Coroutine[str, int, bytes]])

if iscoroutinefunction(y):
if iscoroutinefunction(y): # type: ignore
assert_type(y, Callable[[str, int], Coroutine[Any, Any, bytes]])

if iscoroutinefunction(z):
if iscoroutinefunction(z): # type: ignore
assert_type(z, Callable[[str, int], Coroutine[Any, Any, Any]])

if iscoroutinefunction(xx):
if iscoroutinefunction(xx): # type: ignore
assert_type(xx, Callable[..., Coroutine[Any, Any, Any]])


def test_iscoroutinefunction_inspect(
x: Callable[[str, int], Coroutine[str, int, bytes]],
y: Callable[[str, int], Awaitable[bytes]],
z: Callable[[str, int], str | Awaitable[bytes]],
xx: object,
) -> None:
if inspect.iscoroutinefunction(x):
assert_type(x, Callable[[str, int], Coroutine[str, int, bytes]])

if inspect.iscoroutinefunction(y):
assert_type(y, Callable[[str, int], CoroutineType[Any, Any, bytes]])

if inspect.iscoroutinefunction(z):
assert_type(z, Callable[[str, int], CoroutineType[Any, Any, Any]])

if inspect.iscoroutinefunction(xx):
assert_type(xx, Callable[..., CoroutineType[Any, Any, Any]])
41 changes: 32 additions & 9 deletions stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,38 @@ class _ActionsContainer:
version: str = ...,
**kwargs: Any,
) -> Action: ...
def add_argument_group(
self,
title: str | None = None,
description: str | None = None,
*,
prefix_chars: str = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
) -> _ArgumentGroup: ...
if sys.version_info >= (3, 14):
@overload
def add_argument_group(
self,
title: str | None = None,
description: str | None = None,
*,
argument_default: Any = ...,
conflict_handler: str = ...,
) -> _ArgumentGroup: ...
@overload
@deprecated("Passing 'prefix_chars' to add_argument_group() is deprecated")
def add_argument_group(
self,
title: str | None = None,
description: str | None = None,
*,
prefix_chars: str = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
) -> _ArgumentGroup: ...
else:
def add_argument_group(
self,
title: str | None = None,
description: str | None = None,
*,
prefix_chars: str = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
) -> _ArgumentGroup: ...

def add_mutually_exclusive_group(self, *, required: bool = False) -> _MutuallyExclusiveGroup: ...
def _add_action(self, action: _ActionT) -> _ActionT: ...
def _remove_action(self, action: Action) -> None: ...
Expand Down
6 changes: 5 additions & 1 deletion stdlib/asyncio/coroutines.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from collections.abc import Awaitable, Callable, Coroutine
from typing import Any, TypeVar, overload
from typing_extensions import ParamSpec, TypeGuard, TypeIs
from typing_extensions import ParamSpec, TypeGuard, TypeIs, deprecated

# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 11):
Expand All @@ -17,11 +17,15 @@ if sys.version_info < (3, 11):
def coroutine(func: _FunctionT) -> _FunctionT: ...

@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ...
def iscoroutine(obj: object) -> TypeIs[Coroutine[Any, Any, Any]]: ...
1 change: 1 addition & 0 deletions stdlib/asyncio/unix_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ if sys.platform != "win32":

if sys.version_info >= (3, 14):
_DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy

else:
DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy

Expand Down
3 changes: 2 additions & 1 deletion stdlib/codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from _typeshed import ReadableBuffer
from abc import abstractmethod
from collections.abc import Callable, Generator, Iterable
from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, overload
from typing_extensions import Self, TypeAlias
from typing_extensions import Self, TypeAlias, deprecated

__all__ = [
"register",
Expand Down Expand Up @@ -149,6 +149,7 @@ def getincrementaldecoder(encoding: _BufferedEncoding) -> _BufferedIncrementalDe
def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
def getreader(encoding: str) -> _StreamReader: ...
def getwriter(encoding: str) -> _StreamWriter: ...
@deprecated("codecs.open() is deprecated. Use open() instead.")
def open(
filename: str, mode: str = "r", encoding: str | None = None, errors: str = "strict", buffering: int = -1
) -> StreamReaderWriter: ...
Expand Down
4 changes: 3 additions & 1 deletion stdlib/pathlib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class PurePath(PathLike[str]):
def __rtruediv__(self, key: StrPath) -> Self: ...
def __bytes__(self) -> bytes: ...
def as_posix(self) -> str: ...
@deprecated("PurePath.as_uri() is deprecated. Use Path.as_uri() instead.")
def as_uri(self) -> str: ...
def is_absolute(self) -> bool: ...
def is_reserved(self) -> bool: ...
Expand Down Expand Up @@ -163,7 +164,6 @@ class Path(PurePath):
def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ...

if sys.version_info >= (3, 14):

@property
def info(self) -> PathInfo: ...
@overload
Expand Down Expand Up @@ -300,6 +300,8 @@ class Path(PurePath):
self, top_down: bool = ..., on_error: Callable[[OSError], object] | None = ..., follow_symlinks: bool = ...
) -> Iterator[tuple[Self, list[str], list[str]]]: ...

def as_uri(self) -> str: ...

class PosixPath(Path, PurePosixPath): ...
class WindowsPath(Path, PureWindowsPath): ...

Expand Down
9 changes: 7 additions & 2 deletions stdlib/pdb.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ from inspect import _SourceObjectType
from linecache import _ModuleGlobals
from types import CodeType, FrameType, TracebackType
from typing import IO, Any, ClassVar, Final, Literal, TypeVar
from typing_extensions import ParamSpec, Self, TypeAlias
from typing_extensions import ParamSpec, Self, TypeAlias, deprecated

__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"]
if sys.version_info >= (3, 14):
Expand Down Expand Up @@ -59,7 +59,12 @@ class Pdb(Bdb, Cmd):
stack: list[tuple[FrameType, int]]
curindex: int
curframe: FrameType | None
curframe_locals: Mapping[str, Any]
if sys.version_info >= (3, 13):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.13 due as - The low overhead dynamic frame locals access added in Python 3.13 by PEP 667 means the frame locals cache reference previously stored in this attribute is no longer needed. Derived debuggers should access pdb.Pdb.curframe.f_locals directly in Python 3.13 and later versions.

@property
@deprecated("curframe_locals is deprecated. Derived debuggers should access pdb.Pdb.curframe.f_locals instead.")
def curframe_locals(self) -> Mapping[str, Any]: ...
else:
curframe_locals: Mapping[str, Any]
if sys.version_info >= (3, 14):
mode: _Mode | None
colorize: bool
Expand Down
Loading