1- # Stubs for configparser
2-
31# Based on http://docs.python.org/3.5/library/configparser.html and on
42# reading configparser.py.
53
64from typing import (MutableMapping , Mapping , Dict , Sequence , List , Union ,
7- Iterable , Iterator , Callable , Any , IO , overload , Optional )
5+ Iterable , Iterator , Callable , Any , IO , overload , Optional , Pattern )
86# Types only used in type comments only
97from typing import Optional , Tuple # noqa
108
119# Internal type aliases
12- _section = Dict [str , str ]
10+ _section = Mapping [str , str ]
1311_parser = MutableMapping [str , _section ]
14- _converters = Dict [str , Callable [[str ], Any ]]
15-
16-
17- DEFAULTSECT = ... # type: str
12+ _converter = Callable [[str ], Any ]
13+ _converters = Dict [str , _converter ]
1814
15+ DEFAULTSECT : str
16+ MAX_INTERPOLATION_DEPTH : int
1917
2018class Interpolation :
2119 def before_get (self , parser : _parser ,
@@ -40,27 +38,24 @@ class Interpolation:
4038 value : str ) -> str : ...
4139
4240
43- class BasicInterpolation (Interpolation ):
44- pass
45-
46-
47- class ExtendedInterpolation (Interpolation ):
48- pass
41+ class BasicInterpolation (Interpolation ): ...
42+ class ExtendedInterpolation (Interpolation ): ...
43+ class LegacyInterpolation (Interpolation ): ...
4944
5045
5146class RawConfigParser (_parser ):
5247 def __init__ (self ,
53- defaults : _section = None ,
48+ defaults : Optional [ _section ] = ... ,
5449 dict_type : Mapping [str , str ] = ...,
5550 allow_no_value : bool = ...,
5651 * ,
5752 delimiters : Sequence [str ] = ...,
5853 comment_prefixes : Sequence [str ] = ...,
59- inline_comment_prefixes : Sequence [str ] = None ,
54+ inline_comment_prefixes : Optional [ Sequence [str ]] = ... ,
6055 strict : bool = ...,
6156 empty_lines_in_values : bool = ...,
6257 default_section : str = ...,
63- interpolation : Interpolation = None ) -> None : ...
58+ interpolation : Optional [ Interpolation ] = ... ) -> None : ...
6459
6560 def __len__ (self ) -> int : ...
6661
@@ -134,6 +129,33 @@ class ConfigParser(RawConfigParser):
134129 interpolation : Interpolation = None ,
135130 converters : _converters = ...) -> None : ...
136131
132+ class SafeConfigParser (ConfigParser ): ...
133+
134+ class SectionProxy (MutableMapping [str , str ]):
135+ def __init__ (self , parser : RawConfigParser , name : str ) -> None : ...
136+ def __getitem__ (self , key : str ) -> str : ...
137+ def __setitem__ (self , key : str , value : str ) -> None : ...
138+ def __delitem__ (self , key : str ) -> None : ...
139+ def __contains__ (self , key : object ) -> bool : ...
140+ def __len__ (self ) -> int : ...
141+ def __iter__ (self ) -> Iterator [str ]: ...
142+ @property
143+ def parser (self ) -> RawConfigParser : ...
144+ @property
145+ def name (self ) -> str : ...
146+ def get (self , option : str , fallback : Optional [str ] = ..., * , raw : bool = ..., vars : Optional [_section ] = ..., ** kwargs : Any ) -> str : ... # type: ignore
147+ # SectionProxy can have arbitrary attributes when custon converters are used
148+ def __getattr__ (self , key : str ) -> Callable [..., Any ]: ...
149+
150+ class ConverterMapping (MutableMapping [str , Optional [_converter ]]):
151+ GETTERCRE : Pattern
152+ def __init__ (self , parser : RawConfigParser ) -> None : ...
153+ def __getitem__ (self , key : str ) -> _converter : ...
154+ def __setitem__ (self , key : str , value : Optional [_converter ]) -> None : ...
155+ def __delitem__ (self , key : str ) -> None : ...
156+ def __iter__ (self ) -> Iterator [str ]: ...
157+ def __len__ (self ) -> int : ...
158+
137159
138160class Error (Exception ):
139161 pass
0 commit comments