From a48e61e5c30978ac5c4c15ff6f3acf1a33a628f9 Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Sun, 8 Dec 2024 02:58:08 -0800 Subject: [PATCH 1/2] fix default of dict.get --- stdlib/@tests/stubtest_allowlists/common.txt | 1 - stdlib/builtins.pyi | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index 8a984022920d..2fc473315b55 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -10,7 +10,6 @@ _collections_abc.AsyncGenerator.ag_frame _collections_abc.AsyncGenerator.ag_running asyncio.BaseEventLoop.subprocess_exec # BaseEventLoop adds several parameters and stubtest fails on the difference if we add them asyncio.base_events.BaseEventLoop.subprocess_exec # BaseEventLoop adds several parameters and stubtest fails on the difference if we add them -builtins.dict.get collections\.ChainMap\.fromkeys # https://github.com/python/mypy/issues/17023 configparser.SectionProxy.__getattr__ # SectionProxy can have arbitrary attributes when custom converters are used configparser.SectionProxy.getboolean # SectionProxy get functions are set in __init__ diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index ad10ba9dff4c..9bfa16675859 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1124,7 +1124,7 @@ class dict(MutableMapping[_KT, _VT]): def fromkeys(cls, iterable: Iterable[_T], value: _S, /) -> dict[_T, _S]: ... # Positional-only in dict, but not in MutableMapping @overload # type: ignore[override] - def get(self, key: _KT, /) -> _VT | None: ... + def get(self, key: _KT, default: None = None, /) -> _VT | None: ... @overload def get(self, key: _KT, default: _VT, /) -> _VT: ... @overload From f182d185b3cbddf0a5274cb2f2634926bc184c5d Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Sun, 8 Dec 2024 03:04:27 -0800 Subject: [PATCH 2/2] fix stubtest for 3.10 and 3.11 --- stdlib/importlib/metadata/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index 5e26f8987277..8ab7a0c4a9e8 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -139,7 +139,7 @@ if sys.version_info >= (3, 10) and sys.version_info < (3, 12): class Deprecated(Generic[_KT, _VT]): def __getitem__(self, name: _KT) -> _VT: ... @overload - def get(self, name: _KT) -> _VT | None: ... + def get(self, name: _KT, default: None = None) -> _VT | None: ... @overload def get(self, name: _KT, default: _T) -> _VT | _T: ... def __iter__(self) -> Iterator[_KT]: ...