@@ -124,40 +124,40 @@ class SectionConstraint(object):
124
124
_valid_attrs_ = ("get_value" , "set_value" , "get" , "set" , "getint" , "getfloat" , "getboolean" , "has_option" ,
125
125
"remove_section" , "remove_option" , "options" )
126
126
127
- def __init__ (self , config , section ) :
127
+ def __init__ (self , config : cp . ConfigParser , section : str ) -> None :
128
128
self ._config = config
129
129
self ._section_name = section
130
130
131
- def __del__ (self ):
131
+ def __del__ (self ) -> None :
132
132
# Yes, for some reason, we have to call it explicitly for it to work in PY3 !
133
133
# Apparently __del__ doesn't get call anymore if refcount becomes 0
134
134
# Ridiculous ... .
135
135
self ._config .release ()
136
136
137
- def __getattr__ (self , attr ) :
137
+ def __getattr__ (self , attr : str ) -> Any :
138
138
if attr in self ._valid_attrs_ :
139
139
return lambda * args , ** kwargs : self ._call_config (attr , * args , ** kwargs )
140
140
return super (SectionConstraint , self ).__getattribute__ (attr )
141
141
142
- def _call_config (self , method , * args , ** kwargs ) :
142
+ def _call_config (self , method : str , * args : Any , ** kwargs : Any ) -> Any :
143
143
"""Call the configuration at the given method which must take a section name
144
144
as first argument"""
145
145
return getattr (self ._config , method )(self ._section_name , * args , ** kwargs )
146
146
147
147
@property
148
- def config (self ):
148
+ def config (self ) -> cp . ConfigParser :
149
149
"""return: Configparser instance we constrain"""
150
150
return self ._config
151
151
152
- def release (self ):
152
+ def release (self ) -> None :
153
153
"""Equivalent to GitConfigParser.release(), which is called on our underlying parser instance"""
154
154
return self ._config .release ()
155
155
156
- def __enter__ (self ):
156
+ def __enter__ (self ) -> 'SectionConstraint' :
157
157
self ._config .__enter__ ()
158
158
return self
159
159
160
- def __exit__ (self , exception_type , exception_value , traceback ) :
160
+ def __exit__ (self , exception_type : str , exception_value : str , traceback : str ) -> None :
161
161
self ._config .__exit__ (exception_type , exception_value , traceback )
162
162
163
163
@@ -336,10 +336,10 @@ def __enter__(self):
336
336
self ._acquire_lock ()
337
337
return self
338
338
339
- def __exit__ (self , exception_type , exception_value , traceback ):
339
+ def __exit__ (self , exception_type , exception_value , traceback ) -> None :
340
340
self .release ()
341
341
342
- def release (self ):
342
+ def release (self ) -> None :
343
343
"""Flush changes and release the configuration write lock. This instance must not be used anymore afterwards.
344
344
In Python 3, it's required to explicitly release locks and flush changes, as __del__ is not called
345
345
deterministically anymore."""
0 commit comments