@@ -28,11 +28,10 @@ __all__ = [
28
28
"MAX_INTERPOLATION_DEPTH" ,
29
29
]
30
30
31
- # Internal type aliases
32
- _section : TypeAlias = Mapping [str , str ]
33
- _parser : TypeAlias = MutableMapping [str , _section ]
34
- _converter : TypeAlias = Callable [[str ], Any ]
35
- _converters : TypeAlias = dict [str , _converter ]
31
+ _Section : TypeAlias = Mapping [str , str ]
32
+ _Parser : TypeAlias = MutableMapping [str , _Section ]
33
+ _ConverterCallback : TypeAlias = Callable [[str ], Any ]
34
+ _ConvertersMap : TypeAlias = dict [str , _ConverterCallback ]
36
35
_T = TypeVar ("_T" )
37
36
38
37
if sys .version_info >= (3 , 7 ):
@@ -44,18 +43,18 @@ DEFAULTSECT: Literal["DEFAULT"]
44
43
MAX_INTERPOLATION_DEPTH : Literal [10 ]
45
44
46
45
class Interpolation :
47
- def before_get (self , parser : _parser , section : str , option : str , value : str , defaults : _section ) -> str : ...
48
- def before_set (self , parser : _parser , section : str , option : str , value : str ) -> str : ...
49
- def before_read (self , parser : _parser , section : str , option : str , value : str ) -> str : ...
50
- def before_write (self , parser : _parser , section : str , option : str , value : str ) -> str : ...
46
+ def before_get (self , parser : _Parser , section : str , option : str , value : str , defaults : _Section ) -> str : ...
47
+ def before_set (self , parser : _Parser , section : str , option : str , value : str ) -> str : ...
48
+ def before_read (self , parser : _Parser , section : str , option : str , value : str ) -> str : ...
49
+ def before_write (self , parser : _Parser , section : str , option : str , value : str ) -> str : ...
51
50
52
51
class BasicInterpolation (Interpolation ): ...
53
52
class ExtendedInterpolation (Interpolation ): ...
54
53
55
54
class LegacyInterpolation (Interpolation ):
56
- def before_get (self , parser : _parser , section : str , option : str , value : str , vars : _section ) -> str : ...
55
+ def before_get (self , parser : _Parser , section : str , option : str , value : str , vars : _Section ) -> str : ...
57
56
58
- class RawConfigParser (_parser ):
57
+ class RawConfigParser (_Parser ):
59
58
_SECT_TMPL : ClassVar [str ] # undocumented
60
59
_OPT_TMPL : ClassVar [str ] # undocumented
61
60
_OPT_NV_TMPL : ClassVar [str ] # undocumented
@@ -81,12 +80,12 @@ class RawConfigParser(_parser):
81
80
empty_lines_in_values : bool = ...,
82
81
default_section : str = ...,
83
82
interpolation : Interpolation | None = ...,
84
- converters : _converters = ...,
83
+ converters : _ConvertersMap = ...,
85
84
) -> None : ...
86
85
@overload
87
86
def __init__ (
88
87
self ,
89
- defaults : _section | None = ...,
88
+ defaults : _Section | None = ...,
90
89
dict_type : type [Mapping [str , str ]] = ...,
91
90
allow_no_value : bool = ...,
92
91
* ,
@@ -97,15 +96,15 @@ class RawConfigParser(_parser):
97
96
empty_lines_in_values : bool = ...,
98
97
default_section : str = ...,
99
98
interpolation : Interpolation | None = ...,
100
- converters : _converters = ...,
99
+ converters : _ConvertersMap = ...,
101
100
) -> None : ...
102
101
def __len__ (self ) -> int : ...
103
102
def __getitem__ (self , key : str ) -> SectionProxy : ...
104
- def __setitem__ (self , key : str , value : _section ) -> None : ...
103
+ def __setitem__ (self , key : str , value : _Section ) -> None : ...
105
104
def __delitem__ (self , key : str ) -> None : ...
106
105
def __iter__ (self ) -> Iterator [str ]: ...
107
106
def __contains__ (self , key : object ) -> bool : ...
108
- def defaults (self ) -> _section : ...
107
+ def defaults (self ) -> _Section : ...
109
108
def sections (self ) -> list [str ]: ...
110
109
def add_section (self , section : str ) -> None : ...
111
110
def has_section (self , section : str ) -> bool : ...
@@ -119,22 +118,22 @@ class RawConfigParser(_parser):
119
118
# These get* methods are partially applied (with the same names) in
120
119
# SectionProxy; the stubs should be kept updated together
121
120
@overload
122
- def getint (self , section : str , option : str , * , raw : bool = ..., vars : _section | None = ...) -> int : ...
121
+ def getint (self , section : str , option : str , * , raw : bool = ..., vars : _Section | None = ...) -> int : ...
123
122
@overload
124
123
def getint (
125
- self , section : str , option : str , * , raw : bool = ..., vars : _section | None = ..., fallback : _T = ...
124
+ self , section : str , option : str , * , raw : bool = ..., vars : _Section | None = ..., fallback : _T = ...
126
125
) -> int | _T : ...
127
126
@overload
128
- def getfloat (self , section : str , option : str , * , raw : bool = ..., vars : _section | None = ...) -> float : ...
127
+ def getfloat (self , section : str , option : str , * , raw : bool = ..., vars : _Section | None = ...) -> float : ...
129
128
@overload
130
129
def getfloat (
131
- self , section : str , option : str , * , raw : bool = ..., vars : _section | None = ..., fallback : _T = ...
130
+ self , section : str , option : str , * , raw : bool = ..., vars : _Section | None = ..., fallback : _T = ...
132
131
) -> float | _T : ...
133
132
@overload
134
- def getboolean (self , section : str , option : str , * , raw : bool = ..., vars : _section | None = ...) -> bool : ...
133
+ def getboolean (self , section : str , option : str , * , raw : bool = ..., vars : _Section | None = ...) -> bool : ...
135
134
@overload
136
135
def getboolean (
137
- self , section : str , option : str , * , raw : bool = ..., vars : _section | None = ..., fallback : _T = ...
136
+ self , section : str , option : str , * , raw : bool = ..., vars : _Section | None = ..., fallback : _T = ...
138
137
) -> bool | _T : ...
139
138
def _get_conv (
140
139
self ,
@@ -143,18 +142,18 @@ class RawConfigParser(_parser):
143
142
conv : Callable [[str ], _T ],
144
143
* ,
145
144
raw : bool = ...,
146
- vars : _section | None = ...,
145
+ vars : _Section | None = ...,
147
146
fallback : _T = ...,
148
147
) -> _T : ...
149
148
# This is incompatible with MutableMapping so we ignore the type
150
149
@overload # type: ignore[override]
151
- def get (self , section : str , option : str , * , raw : bool = ..., vars : _section | None = ...) -> str : ...
150
+ def get (self , section : str , option : str , * , raw : bool = ..., vars : _Section | None = ...) -> str : ...
152
151
@overload
153
- def get (self , section : str , option : str , * , raw : bool = ..., vars : _section | None = ..., fallback : _T ) -> str | _T : ...
152
+ def get (self , section : str , option : str , * , raw : bool = ..., vars : _Section | None = ..., fallback : _T ) -> str | _T : ...
154
153
@overload
155
- def items (self , * , raw : bool = ..., vars : _section | None = ...) -> ItemsView [str , SectionProxy ]: ...
154
+ def items (self , * , raw : bool = ..., vars : _Section | None = ...) -> ItemsView [str , SectionProxy ]: ...
156
155
@overload
157
- def items (self , section : str , raw : bool = ..., vars : _section | None = ...) -> list [tuple [str , str ]]: ...
156
+ def items (self , section : str , raw : bool = ..., vars : _Section | None = ...) -> list [tuple [str , str ]]: ...
158
157
def set (self , section : str , option : str , value : str | None = ...) -> None : ...
159
158
def write (self , fp : SupportsWrite [str ], space_around_delimiters : bool = ...) -> None : ...
160
159
def remove_option (self , section : str , option : str ) -> bool : ...
@@ -184,32 +183,32 @@ class SectionProxy(MutableMapping[str, str]):
184
183
fallback : str | None = ...,
185
184
* ,
186
185
raw : bool = ...,
187
- vars : _section | None = ...,
186
+ vars : _Section | None = ...,
188
187
_impl : Any | None = ...,
189
188
** kwargs : Any ,
190
189
) -> str : ...
191
190
# These are partially-applied version of the methods with the same names in
192
191
# RawConfigParser; the stubs should be kept updated together
193
192
@overload
194
- def getint (self , option : str , * , raw : bool = ..., vars : _section | None = ...) -> int : ...
193
+ def getint (self , option : str , * , raw : bool = ..., vars : _Section | None = ...) -> int : ...
195
194
@overload
196
- def getint (self , option : str , fallback : _T = ..., * , raw : bool = ..., vars : _section | None = ...) -> int | _T : ...
195
+ def getint (self , option : str , fallback : _T = ..., * , raw : bool = ..., vars : _Section | None = ...) -> int | _T : ...
197
196
@overload
198
- def getfloat (self , option : str , * , raw : bool = ..., vars : _section | None = ...) -> float : ...
197
+ def getfloat (self , option : str , * , raw : bool = ..., vars : _Section | None = ...) -> float : ...
199
198
@overload
200
- def getfloat (self , option : str , fallback : _T = ..., * , raw : bool = ..., vars : _section | None = ...) -> float | _T : ...
199
+ def getfloat (self , option : str , fallback : _T = ..., * , raw : bool = ..., vars : _Section | None = ...) -> float | _T : ...
201
200
@overload
202
- def getboolean (self , option : str , * , raw : bool = ..., vars : _section | None = ...) -> bool : ...
201
+ def getboolean (self , option : str , * , raw : bool = ..., vars : _Section | None = ...) -> bool : ...
203
202
@overload
204
- def getboolean (self , option : str , fallback : _T = ..., * , raw : bool = ..., vars : _section | None = ...) -> bool | _T : ...
203
+ def getboolean (self , option : str , fallback : _T = ..., * , raw : bool = ..., vars : _Section | None = ...) -> bool | _T : ...
205
204
# SectionProxy can have arbitrary attributes when custom converters are used
206
205
def __getattr__ (self , key : str ) -> Callable [..., Any ]: ...
207
206
208
- class ConverterMapping (MutableMapping [str , _converter | None ]):
209
- GETTERCRE : Pattern [Any ]
207
+ class ConverterMapping (MutableMapping [str , _ConverterCallback | None ]):
208
+ GETTERCRE : ClassVar [ Pattern [Any ] ]
210
209
def __init__ (self , parser : RawConfigParser ) -> None : ...
211
- def __getitem__ (self , key : str ) -> _converter : ...
212
- def __setitem__ (self , key : str , value : _converter | None ) -> None : ...
210
+ def __getitem__ (self , key : str ) -> _ConverterCallback : ...
211
+ def __setitem__ (self , key : str , value : _ConverterCallback | None ) -> None : ...
213
212
def __delitem__ (self , key : str ) -> None : ...
214
213
def __iter__ (self ) -> Iterator [str ]: ...
215
214
def __len__ (self ) -> int : ...
0 commit comments