ConfigParser: accept readline() that takes no arguments (#4433)

At runtime readline() is called without arguments, so requiring
an optional argument may result in false positives.
This commit is contained in:
Jukka Lehtosalo
2020-08-10 15:55:32 +01:00
committed by GitHub
parent 0cd2350595
commit 866b0c3bf0
2 changed files with 5 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
from _typeshed import SupportsReadline
from _typeshed import SupportsNoArgReadline
from typing import IO, Any, Dict, List, Optional, Sequence, Tuple, Union
DEFAULTSECT: str
@@ -66,7 +66,7 @@ class RawConfigParser:
def has_section(self, section: str) -> bool: ...
def options(self, section: str) -> List[str]: ...
def read(self, filenames: Union[str, Sequence[str]]) -> List[str]: ...
def readfp(self, fp: SupportsReadline[str], filename: str = ...) -> None: ...
def readfp(self, fp: SupportsNoArgReadline[str], filename: str = ...) -> None: ...
def get(self, section: str, option: str) -> str: ...
def items(self, section: str) -> List[Tuple[Any, Any]]: ...
def _get(self, section: str, conv: type, option: str) -> Any: ...

View File

@@ -151,6 +151,9 @@ class SupportsRead(Protocol[_T_co]):
class SupportsReadline(Protocol[_T_co]):
def readline(self, __length: int = ...) -> _T_co: ...
class SupportsNoArgReadline(Protocol[_T_co]):
def readline(self) -> _T_co: ...
class SupportsWrite(Protocol[_T_contra]):
def write(self, __s: _T_contra) -> int: ...