Skip to content
Merged
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
15 changes: 9 additions & 6 deletions stdlib/3/configparser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# reading configparser.py.

import sys
from typing import (MutableMapping, Mapping, Dict, Sequence, List, Union,
Iterable, Iterator, Callable, Any, IO, overload, Optional,
Pattern, TypeVar)
from typing import (AbstractSet, MutableMapping, Mapping, Dict, Sequence, List,
Union, Iterable, Iterator, Callable, Any, IO, overload,
Optional, Pattern, TypeVar)
# Types only used in type comments only
from typing import Optional, Tuple # noqa

Expand Down Expand Up @@ -70,7 +70,7 @@ class RawConfigParser(_parser):

def __len__(self) -> int: ...

def __getitem__(self, section: str) -> _section: ...
def __getitem__(self, section: str) -> SectionProxy: ...

def __setitem__(self, section: str, options: _section) -> None: ...

Expand Down Expand Up @@ -112,8 +112,11 @@ class RawConfigParser(_parser):
def get(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: str = ...) -> str: # type: ignore
...

# This is incompatible with Mapping so we ignore the type.
def items(self, section: str = ..., raw: bool = ..., vars: _section = ...) -> Iterable[Tuple[str, _section]]: ... # type: ignore
@overload
def items(self, *, raw: bool = ..., vars: _section = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, return types that are as concrete as possible, and accept types in arguments that are as generic as possible.


@overload
def items(self, section: str, raw: bool = ..., vars: _section = ...) -> List[Tuple[str, str]]: ...

def set(self, section: str, option: str, value: str) -> None: ...

Expand Down