Allow handling None return values of RawConfigParser.get (#8380)

Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
Kevin Kirsche
2022-07-26 18:23:58 -04:00
committed by GitHub
parent d8b0c605ed
commit 41435ef25a

View File

@@ -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