mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Allow handling None return values of RawConfigParser.get (#8380)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user