Skip to content

Commit 2b31ae4

Browse files
Merge branch 'main' into collections_abc_positional_only
2 parents f85e9d3 + 9a9cc18 commit 2b31ae4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1865
-1272
lines changed

stdlib/@tests/stubtest_allowlists/py314.txt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
# ====================================================================
2-
# TODO: New errors in Python 3.14 that need to be fixed or moved below
3-
# ====================================================================
4-
5-
multiprocessing.managers.BaseListProxy.clear
6-
# inspect.signature gives the wrong signature
7-
multiprocessing.managers.BaseListProxy.copy
8-
multiprocessing.managers.DictProxy.__ior__
9-
multiprocessing.managers._BaseDictProxy.__ior__
10-
multiprocessing.managers._BaseDictProxy.__or__
11-
multiprocessing.managers._BaseDictProxy.__reversed__
12-
multiprocessing.managers._BaseDictProxy.__ror__
13-
multiprocessing.managers._BaseDictProxy.fromkeys
14-
15-
161
# =========================
172
# New errors in Python 3.14
183
# =========================
@@ -100,6 +85,9 @@ multiprocessing.managers._BaseSetProxy.__len__
10085
multiprocessing.managers._BaseSetProxy.clear
10186
multiprocessing.managers._BaseSetProxy.copy
10287
multiprocessing.managers._BaseSetProxy.pop
88+
multiprocessing.managers.BaseListProxy.clear
89+
multiprocessing.managers.BaseListProxy.copy
90+
multiprocessing.managers._BaseDictProxy.__reversed__
10391

10492

10593
# =============================================================

stdlib/@tests/test_cases/check_logging.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,27 @@ def record_factory(*args: Any, **kwargs: Any) -> logging.LogRecord:
2828
logging.handlers.QueueListener(queue.Queue())
2929
logging.handlers.QueueListener(queue.SimpleQueue())
3030
logging.handlers.QueueListener(multiprocessing.Queue())
31+
32+
# These all raise at runtime.
33+
logging.basicConfig(filename="foo.log", handlers=[]) # type: ignore
34+
logging.basicConfig(filemode="w", handlers=[]) # type: ignore
35+
logging.basicConfig(stream=None, handlers=[]) # type: ignore
36+
logging.basicConfig(filename="foo.log", stream=None) # type: ignore
37+
logging.basicConfig(filename=None, stream=None) # type: ignore
38+
# These are ok.
39+
logging.basicConfig()
40+
logging.basicConfig(handlers=[])
41+
logging.basicConfig(filename="foo.log", filemode="w")
42+
logging.basicConfig(filename="foo.log", filemode="w", handlers=None)
43+
logging.basicConfig(stream=None)
44+
logging.basicConfig(stream=None, handlers=None)
45+
# dubious but accepted, has same meaning as 'stream=None'.
46+
logging.basicConfig(filename=None)
47+
# These are technically accepted at runtime, but are forbidden in the stubs to help
48+
# prevent user mistakes. Passing 'filemode' / 'encoding' / 'errors' does nothing
49+
# if 'filename' is not specified.
50+
logging.basicConfig(stream=None, filemode="w") # type: ignore
51+
logging.basicConfig(stream=None, encoding="utf-8") # type: ignore
52+
logging.basicConfig(stream=None, errors="strict") # type: ignore
53+
logging.basicConfig(handlers=[], encoding="utf-8") # type: ignore
54+
logging.basicConfig(handlers=[], errors="strict") # type: ignore

stdlib/_thread.pyi

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from collections.abc import Callable
55
from threading import Thread
66
from types import TracebackType
77
from typing import Any, Final, NoReturn, final, overload
8-
from typing_extensions import TypeVarTuple, Unpack, disjoint_base
8+
from typing_extensions import TypeVarTuple, Unpack, deprecated, disjoint_base
99

1010
_Ts = TypeVarTuple("_Ts")
1111

@@ -38,9 +38,12 @@ if sys.version_info >= (3, 13):
3838
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
3939
def release(self) -> None: ...
4040
def locked(self) -> bool: ...
41-
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ...
42-
def release_lock(self) -> None: ...
43-
def locked_lock(self) -> bool: ...
41+
@deprecated("Obsolete synonym. Use `acquire()` instead.")
42+
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented
43+
@deprecated("Obsolete synonym. Use `release()` instead.")
44+
def release_lock(self) -> None: ... # undocumented
45+
@deprecated("Obsolete synonym. Use `locked()` instead.")
46+
def locked_lock(self) -> bool: ... # undocumented
4447
def __enter__(self) -> bool: ...
4548
def __exit__(
4649
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
@@ -53,9 +56,12 @@ else:
5356
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
5457
def release(self) -> None: ...
5558
def locked(self) -> bool: ...
56-
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ...
57-
def release_lock(self) -> None: ...
58-
def locked_lock(self) -> bool: ...
59+
@deprecated("Obsolete synonym. Use `acquire()` instead.")
60+
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented
61+
@deprecated("Obsolete synonym. Use `release()` instead.")
62+
def release_lock(self) -> None: ... # undocumented
63+
@deprecated("Obsolete synonym. Use `locked()` instead.")
64+
def locked_lock(self) -> bool: ... # undocumented
5965
def __enter__(self) -> bool: ...
6066
def __exit__(
6167
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
@@ -65,12 +71,12 @@ else:
6571
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ...
6672
@overload
6773
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
68-
69-
# Obsolete synonym for start_new_thread()
7074
@overload
71-
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ...
75+
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
76+
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ... # undocumented
7277
@overload
73-
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
78+
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
79+
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... # undocumented
7480

7581
if sys.version_info >= (3, 10):
7682
def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ...
@@ -79,9 +85,11 @@ else:
7985
def interrupt_main() -> None: ...
8086

8187
def exit() -> NoReturn: ...
82-
def exit_thread() -> NoReturn: ... # Obsolete synonym for exit()
88+
@deprecated("Obsolete synonym. Use `exit()` instead.")
89+
def exit_thread() -> NoReturn: ... # undocumented
8390
def allocate_lock() -> LockType: ...
84-
def allocate() -> LockType: ... # Obsolete synonym for allocate_lock()
91+
@deprecated("Obsolete synonym. Use `allocate_lock()` instead.")
92+
def allocate() -> LockType: ... # undocumented
8593
def get_ident() -> int: ...
8694
def stack_size(size: int = 0, /) -> int: ...
8795

stdlib/asyncio/tasks.pyi

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,9 @@ else:
369369
async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = None) -> _T: ...
370370

371371
if sys.version_info >= (3, 11):
372-
@overload
373372
async def wait(
374373
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
375374
) -> tuple[set[_FT], set[_FT]]: ...
376-
@overload
377-
async def wait(
378-
fs: Iterable[Task[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
379-
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
380375

381376
elif sys.version_info >= (3, 10):
382377
@overload

stdlib/logging/__init__.pyi

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -576,19 +576,40 @@ if sys.version_info >= (3, 11):
576576
def getLevelNamesMapping() -> dict[str, int]: ...
577577

578578
def makeLogRecord(dict: Mapping[str, object]) -> LogRecord: ...
579+
@overload # handlers is non-None
579580
def basicConfig(
580581
*,
581-
filename: StrPath | None = ...,
582-
filemode: str = ...,
583-
format: str = ...,
584-
datefmt: str | None = ...,
585-
style: _FormatStyle = ...,
586-
level: _Level | None = ...,
587-
stream: SupportsWrite[str] | None = ...,
588-
handlers: Iterable[Handler] | None = ...,
589-
force: bool | None = ...,
590-
encoding: str | None = ...,
591-
errors: str | None = ...,
582+
format: str = ..., # default value depends on the value of `style`
583+
datefmt: str | None = None,
584+
style: _FormatStyle = "%",
585+
level: _Level | None = None,
586+
handlers: Iterable[Handler],
587+
force: bool | None = False,
588+
) -> None: ...
589+
@overload # handlers is None, filename is passed (but possibly None)
590+
def basicConfig(
591+
*,
592+
filename: StrPath | None,
593+
filemode: str = "a",
594+
format: str = ..., # default value depends on the value of `style`
595+
datefmt: str | None = None,
596+
style: _FormatStyle = "%",
597+
level: _Level | None = None,
598+
handlers: None = None,
599+
force: bool | None = False,
600+
encoding: str | None = None,
601+
errors: str | None = "backslashreplace",
602+
) -> None: ...
603+
@overload # handlers is None, filename is not passed
604+
def basicConfig(
605+
*,
606+
format: str = ..., # default value depends on the value of `style`
607+
datefmt: str | None = None,
608+
style: _FormatStyle = "%",
609+
level: _Level | None = None,
610+
stream: SupportsWrite[str] | None = None,
611+
handlers: None = None,
612+
force: bool | None = False,
592613
) -> None: ...
593614
def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented
594615
def setLoggerClass(klass: type[Logger]) -> None: ...

stdlib/multiprocessing/managers.pyi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ from .util import Finalize as _Finalize
2626
__all__ = ["BaseManager", "SyncManager", "BaseProxy", "Token", "SharedMemoryManager"]
2727

2828
_T = TypeVar("_T")
29+
_T1 = TypeVar("_T1")
30+
_T2 = TypeVar("_T2")
2931
_KT = TypeVar("_KT")
3032
_VT = TypeVar("_VT")
3133
_S = TypeVar("_S")
@@ -94,6 +96,25 @@ if sys.version_info >= (3, 13):
9496
def keys(self) -> list[_KT]: ... # type: ignore[override]
9597
def items(self) -> list[tuple[_KT, _VT]]: ... # type: ignore[override]
9698
def values(self) -> list[_VT]: ... # type: ignore[override]
99+
if sys.version_info >= (3, 14):
100+
# Next methods are copied from builtins.dict
101+
@overload
102+
def fromkeys(self, iterable: Iterable[_T], value: None = None, /) -> dict[_T, Any | None]: ...
103+
@overload
104+
def fromkeys(self, iterable: Iterable[_T], value: _S, /) -> dict[_T, _S]: ...
105+
def __reversed__(self) -> Iterator[_KT]: ...
106+
@overload
107+
def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
108+
@overload
109+
def __or__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
110+
@overload
111+
def __ror__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
112+
@overload
113+
def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
114+
@overload # type: ignore[misc]
115+
def __ior__(self, value: SupportsKeysAndGetItem[_KT, _VT], /) -> Self: ...
116+
@overload
117+
def __ior__(self, value: Iterable[tuple[_KT, _VT]], /) -> Self: ...
97118

98119
class DictProxy(_BaseDictProxy[_KT, _VT]):
99120
def __class_getitem__(cls, args: Any, /) -> GenericAlias: ...
@@ -193,6 +214,8 @@ class BaseListProxy(BaseProxy, MutableSequence[_T]):
193214
def insert(self, index: SupportsIndex, object: _T, /) -> None: ...
194215
def remove(self, value: _T, /) -> None: ...
195216
if sys.version_info >= (3, 14):
217+
# Next methods are copied from builtins.list
218+
def clear(self) -> None: ...
196219
def copy(self) -> list[_T]: ...
197220
# Use BaseListProxy[SupportsRichComparisonT] for the first overload rather than [SupportsRichComparison]
198221
# to work around invariance

stdlib/multiprocessing/queues.pyi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import sys
22
from types import GenericAlias
3-
from typing import Any, Generic, TypeVar
3+
from typing import Any, Generic, NewType, TypeVar
44

55
__all__ = ["Queue", "SimpleQueue", "JoinableQueue"]
66

77
_T = TypeVar("_T")
88

9+
_QueueState = NewType("_QueueState", object)
10+
_JoinableQueueState = NewType("_JoinableQueueState", object)
11+
_SimpleQueueState = NewType("_SimpleQueueState", object)
12+
913
class Queue(Generic[_T]):
1014
# FIXME: `ctx` is a circular dependency and it's not actually optional.
1115
# It's marked as such to be able to use the generic Queue in __init__.pyi.
1216
def __init__(self, maxsize: int = 0, *, ctx: Any = ...) -> None: ...
17+
def __getstate__(self) -> _QueueState: ...
18+
def __setstate__(self, state: _QueueState) -> None: ...
1319
def put(self, obj: _T, block: bool = True, timeout: float | None = None) -> None: ...
1420
def get(self, block: bool = True, timeout: float | None = None) -> _T: ...
1521
def qsize(self) -> int: ...
@@ -24,13 +30,17 @@ class Queue(Generic[_T]):
2430
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
2531

2632
class JoinableQueue(Queue[_T]):
33+
def __getstate__(self) -> _JoinableQueueState: ... # type: ignore[override]
34+
def __setstate__(self, state: _JoinableQueueState) -> None: ... # type: ignore[override]
2735
def task_done(self) -> None: ...
2836
def join(self) -> None: ...
2937

3038
class SimpleQueue(Generic[_T]):
3139
def __init__(self, *, ctx: Any = ...) -> None: ...
3240
def close(self) -> None: ...
3341
def empty(self) -> bool: ...
42+
def __getstate__(self) -> _SimpleQueueState: ...
43+
def __setstate__(self, state: _SimpleQueueState) -> None: ...
3444
def get(self) -> _T: ...
3545
def put(self, obj: _T) -> None: ...
3646
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

stdlib/opcode.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if sys.version_info >= (3, 13):
4141
opname: Final[list[str]]
4242

4343
opmap: Final[dict[str, int]]
44-
HAVE_ARGUMENT: Final = 43
45-
EXTENDED_ARG: Final = 69
44+
HAVE_ARGUMENT: Final[int]
45+
EXTENDED_ARG: Final[int]
4646

4747
def stack_effect(opcode: int, oparg: int | None = None, /, *, jump: bool | None = None) -> int: ...

stdlib/pickle.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from _pickle import (
23
PickleError as PickleError,
34
Pickler as Pickler,
@@ -103,7 +104,10 @@ __all__ = [
103104
]
104105

105106
HIGHEST_PROTOCOL: Final = 5
106-
DEFAULT_PROTOCOL: Final = 5
107+
if sys.version_info >= (3, 14):
108+
DEFAULT_PROTOCOL: Final = 5
109+
else:
110+
DEFAULT_PROTOCOL: Final = 4
107111

108112
bytes_types: tuple[type[Any], ...] # undocumented
109113

stubs/Authlib/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version = "1.6.7"
1+
version = "1.6.8"
22
upstream_repository = "https://github.com/authlib/authlib"
33
requires = ["cryptography"]

0 commit comments

Comments
 (0)