@@ -5,31 +5,53 @@ from re import Pattern
55from typing import Any , ClassVar , TypeVar , overload
66from typing_extensions import Literal , TypeAlias
77
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+ ]
3355
3456_Section : TypeAlias = Mapping [str , str ]
3557_Parser : TypeAlias = MutableMapping [str , _Section ]
@@ -128,7 +150,8 @@ class RawConfigParser(_Parser):
128150 def read_file (self , f : Iterable [str ], source : str | None = None ) -> None : ...
129151 def read_string (self , string : str , source : str = "<string>" ) -> None : ...
130152 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 : ...
132155 # These get* methods are partially applied (with the same names) in
133156 # SectionProxy; the stubs should be kept updated together
134157 @overload
@@ -277,7 +300,11 @@ class InterpolationSyntaxError(InterpolationError): ...
277300class ParsingError (Error ):
278301 source : str
279302 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+
281308 def append (self , lineno : int , line : str ) -> None : ...
282309
283310class MissingSectionHeaderError (ParsingError ):
0 commit comments