massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / configparser.pyi
1 import sys
2 from _typeshed import StrOrBytesPath, StrPath, SupportsWrite
3 from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence
4 from typing import Any, ClassVar, Dict, Optional, Pattern, Type, TypeVar, overload
5 from typing_extensions import Literal
6
7 # Internal type aliases
8 _section = Mapping[str, str]
9 _parser = MutableMapping[str, _section]
10 _converter = Callable[[str], Any]
11 _converters = Dict[str, _converter]
12 _T = TypeVar("_T")
13
14 if sys.version_info >= (3, 7):
15     _Path = StrOrBytesPath
16 else:
17     _Path = StrPath
18
19 DEFAULTSECT: str
20 MAX_INTERPOLATION_DEPTH: int
21
22 class Interpolation:
23     def before_get(self, parser: _parser, section: str, option: str, value: str, defaults: _section) -> str: ...
24     def before_set(self, parser: _parser, section: str, option: str, value: str) -> str: ...
25     def before_read(self, parser: _parser, section: str, option: str, value: str) -> str: ...
26     def before_write(self, parser: _parser, section: str, option: str, value: str) -> str: ...
27
28 class BasicInterpolation(Interpolation): ...
29 class ExtendedInterpolation(Interpolation): ...
30
31 class LegacyInterpolation(Interpolation):
32     def before_get(self, parser: _parser, section: str, option: str, value: str, vars: _section) -> str: ...
33
34 class RawConfigParser(_parser):
35     _SECT_TMPL: ClassVar[str]  # undocumented
36     _OPT_TMPL: ClassVar[str]  # undocumented
37     _OPT_NV_TMPL: ClassVar[str]  # undocumented
38
39     SECTCRE: Pattern[str]
40     OPTCRE: ClassVar[Pattern[str]]
41     OPTCRE_NV: ClassVar[Pattern[str]]  # undocumented
42     NONSPACECRE: ClassVar[Pattern[str]]  # undocumented
43
44     BOOLEAN_STATES: ClassVar[Mapping[str, bool]]  # undocumented
45     default_section: str
46     @overload
47     def __init__(
48         self,
49         defaults: Mapping[str, str | None] | None = ...,
50         dict_type: Type[Mapping[str, str]] = ...,
51         allow_no_value: Literal[True] = ...,
52         *,
53         delimiters: Sequence[str] = ...,
54         comment_prefixes: Sequence[str] = ...,
55         inline_comment_prefixes: Sequence[str] | None = ...,
56         strict: bool = ...,
57         empty_lines_in_values: bool = ...,
58         default_section: str = ...,
59         interpolation: Interpolation | None = ...,
60         converters: _converters = ...,
61     ) -> None: ...
62     @overload
63     def __init__(
64         self,
65         defaults: _section | None = ...,
66         dict_type: Type[Mapping[str, str]] = ...,
67         allow_no_value: bool = ...,
68         *,
69         delimiters: Sequence[str] = ...,
70         comment_prefixes: Sequence[str] = ...,
71         inline_comment_prefixes: Sequence[str] | None = ...,
72         strict: bool = ...,
73         empty_lines_in_values: bool = ...,
74         default_section: str = ...,
75         interpolation: Interpolation | None = ...,
76         converters: _converters = ...,
77     ) -> None: ...
78     def __len__(self) -> int: ...
79     def __getitem__(self, section: str) -> SectionProxy: ...
80     def __setitem__(self, section: str, options: _section) -> None: ...
81     def __delitem__(self, section: str) -> None: ...
82     def __iter__(self) -> Iterator[str]: ...
83     def defaults(self) -> _section: ...
84     def sections(self) -> list[str]: ...
85     def add_section(self, section: str) -> None: ...
86     def has_section(self, section: str) -> bool: ...
87     def options(self, section: str) -> list[str]: ...
88     def has_option(self, section: str, option: str) -> bool: ...
89     def read(self, filenames: _Path | Iterable[_Path], encoding: str | None = ...) -> list[str]: ...
90     def read_file(self, f: Iterable[str], source: str | None = ...) -> None: ...
91     def read_string(self, string: str, source: str = ...) -> None: ...
92     def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = ...) -> None: ...
93     def readfp(self, fp: Iterable[str], filename: str | None = ...) -> None: ...
94     # These get* methods are partially applied (with the same names) in
95     # SectionProxy; the stubs should be kept updated together
96     @overload
97     def getint(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> int: ...
98     @overload
99     def getint(
100         self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ...
101     ) -> int | _T: ...
102     @overload
103     def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ...
104     @overload
105     def getfloat(
106         self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ...
107     ) -> float | _T: ...
108     @overload
109     def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ...
110     @overload
111     def getboolean(
112         self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ...
113     ) -> bool | _T: ...
114     def _get_conv(
115         self,
116         section: str,
117         option: str,
118         conv: Callable[[str], _T],
119         *,
120         raw: bool = ...,
121         vars: _section | None = ...,
122         fallback: _T = ...,
123     ) -> _T: ...
124     # This is incompatible with MutableMapping so we ignore the type
125     @overload  # type: ignore
126     def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> str: ...
127     @overload
128     def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T) -> str | _T: ...
129     @overload
130     def items(self, *, raw: bool = ..., vars: _section | None = ...) -> ItemsView[str, SectionProxy]: ...
131     @overload
132     def items(self, section: str, raw: bool = ..., vars: _section | None = ...) -> list[tuple[str, str]]: ...
133     def set(self, section: str, option: str, value: str | None = ...) -> None: ...
134     def write(self, fp: SupportsWrite[str], space_around_delimiters: bool = ...) -> None: ...
135     def remove_option(self, section: str, option: str) -> bool: ...
136     def remove_section(self, section: str) -> bool: ...
137     def optionxform(self, optionstr: str) -> str: ...
138
139 class ConfigParser(RawConfigParser): ...
140 class SafeConfigParser(ConfigParser): ...
141
142 class SectionProxy(MutableMapping[str, str]):
143     def __init__(self, parser: RawConfigParser, name: str) -> None: ...
144     def __getitem__(self, key: str) -> str: ...
145     def __setitem__(self, key: str, value: str) -> None: ...
146     def __delitem__(self, key: str) -> None: ...
147     def __contains__(self, key: object) -> bool: ...
148     def __len__(self) -> int: ...
149     def __iter__(self) -> Iterator[str]: ...
150     @property
151     def parser(self) -> RawConfigParser: ...
152     @property
153     def name(self) -> str: ...
154     def get(self, option: str, fallback: str | None = ..., *, raw: bool = ..., vars: _section | None = ..., _impl: Any | None = ..., **kwargs: Any) -> str: ...  # type: ignore
155     # These are partially-applied version of the methods with the same names in
156     # RawConfigParser; the stubs should be kept updated together
157     @overload
158     def getint(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> int: ...
159     @overload
160     def getint(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> int | _T: ...
161     @overload
162     def getfloat(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ...
163     @overload
164     def getfloat(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> float | _T: ...
165     @overload
166     def getboolean(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ...
167     @overload
168     def getboolean(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> bool | _T: ...
169     # SectionProxy can have arbitrary attributes when custom converters are used
170     def __getattr__(self, key: str) -> Callable[..., Any]: ...
171
172 class ConverterMapping(MutableMapping[str, Optional[_converter]]):
173     GETTERCRE: Pattern[Any]
174     def __init__(self, parser: RawConfigParser) -> None: ...
175     def __getitem__(self, key: str) -> _converter: ...
176     def __setitem__(self, key: str, value: _converter | None) -> None: ...
177     def __delitem__(self, key: str) -> None: ...
178     def __iter__(self) -> Iterator[str]: ...
179     def __len__(self) -> int: ...
180
181 class Error(Exception):
182     message: str
183     def __init__(self, msg: str = ...) -> None: ...
184
185 class NoSectionError(Error):
186     section: str
187     def __init__(self, section: str) -> None: ...
188
189 class DuplicateSectionError(Error):
190     section: str
191     source: str | None
192     lineno: int | None
193     def __init__(self, section: str, source: str | None = ..., lineno: int | None = ...) -> None: ...
194
195 class DuplicateOptionError(Error):
196     section: str
197     option: str
198     source: str | None
199     lineno: int | None
200     def __init__(self, section: str, option: str, source: str | None = ..., lineno: int | None = ...) -> None: ...
201
202 class NoOptionError(Error):
203     section: str
204     option: str
205     def __init__(self, option: str, section: str) -> None: ...
206
207 class InterpolationError(Error):
208     section: str
209     option: str
210     def __init__(self, option: str, section: str, msg: str) -> None: ...
211
212 class InterpolationDepthError(InterpolationError):
213     def __init__(self, option: str, section: str, rawval: object) -> None: ...
214
215 class InterpolationMissingOptionError(InterpolationError):
216     reference: str
217     def __init__(self, option: str, section: str, rawval: object, reference: str) -> None: ...
218
219 class InterpolationSyntaxError(InterpolationError): ...
220
221 class ParsingError(Error):
222     source: str
223     errors: list[tuple[int, str]]
224     def __init__(self, source: str | None = ..., filename: str | None = ...) -> None: ...
225     def append(self, lineno: int, line: str) -> None: ...
226
227 class MissingSectionHeaderError(ParsingError):
228     lineno: int
229     line: str
230     def __init__(self, filename: str, lineno: int, line: str) -> None: ...