@@ -5,31 +5,53 @@ from re import Pattern
5
5
from typing import Any , ClassVar , TypeVar , overload
6
6
from typing_extensions import Literal , TypeAlias
7
7
8
- __all__ = [
9
- "NoSectionError" ,
10
- "DuplicateOptionError" ,
11
- "DuplicateSectionError" ,
12
- "NoOptionError" ,
13
- "InterpolationError" ,
14
- "InterpolationDepthError" ,
15
- "InterpolationMissingOptionError" ,
16
- "InterpolationSyntaxError" ,
17
- "ParsingError" ,
18
- "MissingSectionHeaderError" ,
19
- "ConfigParser" ,
20
- "RawConfigParser" ,
21
- "Interpolation" ,
22
- "BasicInterpolation" ,
23
- "ExtendedInterpolation" ,
24
- "LegacyInterpolation" ,
25
- "SectionProxy" ,
26
- "ConverterMapping" ,
27
- "DEFAULTSECT" ,
28
- "MAX_INTERPOLATION_DEPTH" ,
29
- ]
30
-
31
- if sys .version_info < (3 , 12 ):
32
- __all__ += ["SafeConfigParser" ]
8
+ if sys .version_info >= (3 , 12 ):
9
+ __all__ = (
10
+ "NoSectionError" ,
11
+ "DuplicateOptionError" ,
12
+ "DuplicateSectionError" ,
13
+ "NoOptionError" ,
14
+ "InterpolationError" ,
15
+ "InterpolationDepthError" ,
16
+ "InterpolationMissingOptionError" ,
17
+ "InterpolationSyntaxError" ,
18
+ "ParsingError" ,
19
+ "MissingSectionHeaderError" ,
20
+ "ConfigParser" ,
21
+ "RawConfigParser" ,
22
+ "Interpolation" ,
23
+ "BasicInterpolation" ,
24
+ "ExtendedInterpolation" ,
25
+ "LegacyInterpolation" ,
26
+ "SectionProxy" ,
27
+ "ConverterMapping" ,
28
+ "DEFAULTSECT" ,
29
+ "MAX_INTERPOLATION_DEPTH" ,
30
+ )
31
+ else :
32
+ __all__ = [
33
+ "NoSectionError" ,
34
+ "DuplicateOptionError" ,
35
+ "DuplicateSectionError" ,
36
+ "NoOptionError" ,
37
+ "InterpolationError" ,
38
+ "InterpolationDepthError" ,
39
+ "InterpolationMissingOptionError" ,
40
+ "InterpolationSyntaxError" ,
41
+ "ParsingError" ,
42
+ "MissingSectionHeaderError" ,
43
+ "ConfigParser" ,
44
+ "SafeConfigParser" ,
45
+ "RawConfigParser" ,
46
+ "Interpolation" ,
47
+ "BasicInterpolation" ,
48
+ "ExtendedInterpolation" ,
49
+ "LegacyInterpolation" ,
50
+ "SectionProxy" ,
51
+ "ConverterMapping" ,
52
+ "DEFAULTSECT" ,
53
+ "MAX_INTERPOLATION_DEPTH" ,
54
+ ]
33
55
34
56
_Section : TypeAlias = Mapping [str , str ]
35
57
_Parser : TypeAlias = MutableMapping [str , _Section ]
@@ -128,7 +150,8 @@ class RawConfigParser(_Parser):
128
150
def read_file (self , f : Iterable [str ], source : str | None = None ) -> None : ...
129
151
def read_string (self , string : str , source : str = "<string>" ) -> None : ...
130
152
def read_dict (self , dictionary : Mapping [str , Mapping [str , Any ]], source : str = "<dict>" ) -> None : ...
131
- def readfp (self , fp : Iterable [str ], filename : str | None = None ) -> None : ...
153
+ if sys .version_info < (3 , 12 ):
154
+ def readfp (self , fp : Iterable [str ], filename : str | None = None ) -> None : ...
132
155
# These get* methods are partially applied (with the same names) in
133
156
# SectionProxy; the stubs should be kept updated together
134
157
@overload
@@ -277,7 +300,11 @@ class InterpolationSyntaxError(InterpolationError): ...
277
300
class ParsingError (Error ):
278
301
source : str
279
302
errors : list [tuple [int , str ]]
280
- def __init__ (self , source : str | None = None , filename : str | None = None ) -> None : ...
303
+ if sys .version_info >= (3 , 12 ):
304
+ def __init__ (self , source : str ) -> None : ...
305
+ else :
306
+ def __init__ (self , source : str | None = None , filename : str | None = None ) -> None : ...
307
+
281
308
def append (self , lineno : int , line : str ) -> None : ...
282
309
283
310
class MissingSectionHeaderError (ParsingError ):
0 commit comments