From d261f1488684b4db4020b4236eff417d4f08900b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 10 Jun 2020 12:32:18 -0700 Subject: [PATCH] add constructors for configparser errors (#4215) Fixes #4058 Co-authored-by: Shantanu --- stdlib/3/configparser.pyi | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/stdlib/3/configparser.pyi b/stdlib/3/configparser.pyi index d40bf5af1..aee931eaa 100644 --- a/stdlib/3/configparser.pyi +++ b/stdlib/3/configparser.pyi @@ -190,16 +190,21 @@ class ConverterMapping(MutableMapping[str, Optional[_converter]]): def __len__(self) -> int: ... -class Error(Exception): ... +class Error(Exception): + message: str + def __init__(self, msg: str = ...) -> None: ... -class NoSectionError(Error): ... +class NoSectionError(Error): + section: str + def __init__(self, section: str) -> None: ... class DuplicateSectionError(Error): section: str source: Optional[str] lineno: Optional[int] + def __init__(self, section: str, source: Optional[str] = ..., lineno: Optional[int] = ...) -> None: ... class DuplicateOptionError(Error): @@ -207,23 +212,28 @@ class DuplicateOptionError(Error): option: str source: Optional[str] lineno: Optional[int] + def __init__(self, section: str, option: str, source: Optional[str] = ..., lineno: Optional[str] = ...) -> None: ... class NoOptionError(Error): section: str option: str + def __init__(self, option: str, section: str) -> None: ... class InterpolationError(Error): section: str option: str + def __init__(self, option: str, section: str, msg: str) -> None: ... -class InterpolationDepthError(InterpolationError): ... +class InterpolationDepthError(InterpolationError): + def __init__(self, option: str, section: str, rawval: object) -> None: ... class InterpolationMissingOptionError(InterpolationError): reference: str + def __init__(self, option: str, section: str, rawval: object, reference: str) -> None: ... class InterpolationSyntaxError(InterpolationError): ... @@ -231,9 +241,12 @@ class InterpolationSyntaxError(InterpolationError): ... class ParsingError(Error): source: str - errors: Sequence[Tuple[int, str]] + errors: List[Tuple[int, str]] + def __init__(self, source: Optional[str] = ..., filename: Optional[str] = ...) -> None: ... + def append(self, lineno: int, line: str) -> None: ... class MissingSectionHeaderError(ParsingError): lineno: int line: str + def __init__(self, filename: str, lineno: int, line: str) -> None: ...