diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 98ddb95f5..00a23588b 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -143,9 +143,9 @@ class RawConfigParser(_Parser): ) -> _T: ... # This is incompatible with MutableMapping so we ignore the type @overload # type: ignore[override] - def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> str: ... + def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> str | Any: ... @overload - def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T) -> str | _T: ... + def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T) -> str | _T | Any: ... @overload def items(self, *, raw: bool = ..., vars: _Section | None = ...) -> ItemsView[str, SectionProxy]: ... @overload @@ -156,7 +156,12 @@ class RawConfigParser(_Parser): def remove_section(self, section: str) -> bool: ... def optionxform(self, optionstr: str) -> str: ... -class ConfigParser(RawConfigParser): ... +class ConfigParser(RawConfigParser): + # This is incompatible with MutableMapping so we ignore the type + @overload # type: ignore[override] + def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> str: ... + @overload + def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T) -> str | _T: ... if sys.version_info < (3, 12): class SafeConfigParser(ConfigParser): ... # deprecated alias @@ -182,7 +187,7 @@ class SectionProxy(MutableMapping[str, str]): vars: _Section | None = ..., _impl: Any | None = ..., **kwargs: Any, - ) -> str: ... + ) -> str | Any: ... # can be None in RawConfigParser's sections # These are partially-applied version of the methods with the same names in # RawConfigParser; the stubs should be kept updated together @overload