From 866b0c3bf0cbd791d4c2072526568abd74463e84 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Mon, 10 Aug 2020 15:55:32 +0100 Subject: [PATCH] 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. --- stdlib/2/ConfigParser.pyi | 4 ++-- stdlib/2and3/_typeshed/__init__.pyi | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stdlib/2/ConfigParser.pyi b/stdlib/2/ConfigParser.pyi index 08812848d..80f0ab1d4 100644 --- a/stdlib/2/ConfigParser.pyi +++ b/stdlib/2/ConfigParser.pyi @@ -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: ... diff --git a/stdlib/2and3/_typeshed/__init__.pyi b/stdlib/2and3/_typeshed/__init__.pyi index ed5154364..1236bbdd9 100644 --- a/stdlib/2and3/_typeshed/__init__.pyi +++ b/stdlib/2and3/_typeshed/__init__.pyi @@ -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: ...