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.
This commit is contained in:
The Fox in the Shell
2019-05-06 16:00:52 +00:00
committed by Jelle Zijlstra
parent e67961e387
commit e7d7a44411

View File

@@ -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]]: ...