Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overload w.r.t. fallback parameter to configparser.SectionProxy.get #12935

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions stdlib/configparser.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from _typeshed import StrOrBytesPath, SupportsWrite
from _typeshed import MaybeNone, StrOrBytesPath, SupportsWrite
from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence
from re import Pattern
from typing import Any, ClassVar, Final, Literal, TypeVar, overload
Expand Down Expand Up @@ -263,11 +263,11 @@ 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 = False, vars: _Section | None = None) -> str | Any: ...
def get(self, section: str, option: str, *, raw: bool = False, vars: _Section | None = None) -> str | MaybeNone: ...
@overload
def get(
self, section: str, option: str, *, raw: bool = False, vars: _Section | None = None, fallback: _T
) -> str | _T | Any: ...
) -> str | _T | MaybeNone: ...
@overload
def items(self, *, raw: bool = False, vars: _Section | None = None) -> ItemsView[str, SectionProxy]: ...
@overload
Expand Down Expand Up @@ -300,16 +300,22 @@ class SectionProxy(MutableMapping[str, str]):
def parser(self) -> RawConfigParser: ...
@property
def name(self) -> str: ...
def get( # type: ignore[override]
# This is incompatible with MutableMapping so we ignore the type
@overload # type: ignore[override]
def get(
self, option: str, *, raw: bool = False, vars: _Section | None = None, _impl: Any | None = None, **kwargs: Any
) -> str | MaybeNone: ... # can be None in RawConfigParser's sections
@overload
def get(
self,
option: str,
fallback: str | None = None,
fallback: _T,
*,
raw: bool = False,
vars: _Section | None = None,
_impl: Any | None = None,
**kwargs: Any,
) -> str | Any: ... # can be None in RawConfigParser's sections
) -> str | _T: ...
# These are partially-applied version of the methods with the same names in
# RawConfigParser; the stubs should be kept updated together
@overload
Expand Down