From f1b121cf29b509b6f4da58add2741c139f8362d1 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 28 Feb 2025 12:33:10 +0100 Subject: [PATCH] [configparser] Fix missing fallback argument in SectionProxy.get (#13559) Closes: #13556 --- stdlib/@tests/test_cases/check_configparser.py | 5 +++++ stdlib/configparser.pyi | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 stdlib/@tests/test_cases/check_configparser.py diff --git a/stdlib/@tests/test_cases/check_configparser.py b/stdlib/@tests/test_cases/check_configparser.py new file mode 100644 index 000000000..28c355f38 --- /dev/null +++ b/stdlib/@tests/test_cases/check_configparser.py @@ -0,0 +1,5 @@ +from configparser import RawConfigParser, SectionProxy +from typing_extensions import assert_type + +sp = SectionProxy(RawConfigParser(), "") +assert_type(sp.get("foo", fallback="hi"), str) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index bc3e22771..8996c85d9 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -320,7 +320,14 @@ class SectionProxy(MutableMapping[str, str]): # This is incompatible with MutableMapping so we ignore the type @overload # type: ignore[override] def get( - self, option: str, *, raw: bool = False, vars: _Section | None = None, _impl: Any | None = None, **kwargs: Any + self, + option: str, + fallback: None = None, + *, + raw: bool = False, + vars: _Section | None = None, + _impl: Any | None = None, + **kwargs: Any, # passed to the underlying parser's get() method ) -> str | None: ... @overload def get( @@ -331,7 +338,7 @@ class SectionProxy(MutableMapping[str, str]): raw: bool = False, vars: _Section | None = None, _impl: Any | None = None, - **kwargs: Any, + **kwargs: Any, # passed to the underlying parser's get() method ) -> str | _T: ... # These are partially-applied version of the methods with the same names in # RawConfigParser; the stubs should be kept updated together