From e7d7a444112faebcf2b97594dd387b4a3f760ecc Mon Sep 17 00:00:00 2001 From: The Fox in the Shell Date: Mon, 6 May 2019 16:00:52 +0000 Subject: [PATCH] Make the signature of ConfigParser.get() polymorphic (#2406) The documentation [explicitly specifies](https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.get) that `None` is a legitimate `fallback` value. Thanks to @wiml for suggesting this approach. --- stdlib/3/configparser.pyi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stdlib/3/configparser.pyi b/stdlib/3/configparser.pyi index 97df5265b..17501c1e9 100644 --- a/stdlib/3/configparser.pyi +++ b/stdlib/3/configparser.pyi @@ -111,8 +111,11 @@ class RawConfigParser(_parser): def _get_conv(self, section: str, option: str, conv: Callable[[str], _T], *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ...) -> _T: ... # This is incompatible with MutableMapping so we ignore the type - def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: str = ...) -> str: # type: ignore - ... + @overload # type: ignore + def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> str: ... + + @overload # type: ignore + def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T) -> Union[str, _T]: ... @overload def items(self, *, raw: bool = ..., vars: Optional[_section] = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ...