From 6f848e8ed8744db446718f52d1eab019768cf645 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Mon, 21 Aug 2017 17:09:42 -0400 Subject: [PATCH] Add definition for RawConfigParser._get_conv (#1542) This allows subclasses that define get* methods to wrap _get_conv whilst still typechecking correctly. --- stdlib/3/configparser.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/3/configparser.pyi b/stdlib/3/configparser.pyi index 6946c6dbd..c481852b5 100644 --- a/stdlib/3/configparser.pyi +++ b/stdlib/3/configparser.pyi @@ -3,7 +3,8 @@ import sys from typing import (MutableMapping, Mapping, Dict, Sequence, List, Union, - Iterable, Iterator, Callable, Any, IO, Optional, Pattern) + Iterable, Iterator, Callable, Any, IO, overload, Optional, + Pattern, TypeVar) # Types only used in type comments only from typing import Optional, Tuple # noqa @@ -15,6 +16,7 @@ _section = Mapping[str, str] _parser = MutableMapping[str, _section] _converter = Callable[[str], Any] _converters = Dict[str, _converter] +_T = TypeVar('_T') if sys.version_info >= (3, 6): _Path = Union[str, PathLike[str]] @@ -104,6 +106,8 @@ class RawConfigParser(_parser): def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: bool = ...) -> bool: ... + def _get_conv(self, section: str, option: str, conv: Callable[[str], _T], *, raw: bool = ..., vars: _section = ..., fallback: _T = ...) -> _T: ... + # This is incompatible with MutableMapping so we ignore the type def get(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: str = ...) -> str: # type: ignore ...