Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e331a0

Browse files
committed
Add types to config.py class SectionConstraint
1 parentefe6833 commit6e331a0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

‎git/config.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,40 +124,40 @@ class SectionConstraint(object):
124124
_valid_attrs_= ("get_value","set_value","get","set","getint","getfloat","getboolean","has_option",
125125
"remove_section","remove_option","options")
126126

127-
def__init__(self,config,section):
127+
def__init__(self,config:cp.ConfigParser,section:str)->None:
128128
self._config=config
129129
self._section_name=section
130130

131-
def__del__(self):
131+
def__del__(self)->None:
132132
# Yes, for some reason, we have to call it explicitly for it to work in PY3 !
133133
# Apparently __del__ doesn't get call anymore if refcount becomes 0
134134
# Ridiculous ... .
135135
self._config.release()
136136

137-
def__getattr__(self,attr):
137+
def__getattr__(self,attr:str)->Any:
138138
ifattrinself._valid_attrs_:
139139
returnlambda*args,**kwargs:self._call_config(attr,*args,**kwargs)
140140
returnsuper(SectionConstraint,self).__getattribute__(attr)
141141

142-
def_call_config(self,method,*args,**kwargs):
142+
def_call_config(self,method:str,*args:Any,**kwargs:Any)->Any:
143143
"""Call the configuration at the given method which must take a section name
144144
as first argument"""
145145
returngetattr(self._config,method)(self._section_name,*args,**kwargs)
146146

147147
@property
148-
defconfig(self):
148+
defconfig(self)->cp.ConfigParser:
149149
"""return: Configparser instance we constrain"""
150150
returnself._config
151151

152-
defrelease(self):
152+
defrelease(self)->None:
153153
"""Equivalent to GitConfigParser.release(), which is called on our underlying parser instance"""
154154
returnself._config.release()
155155

156-
def__enter__(self):
156+
def__enter__(self)->'SectionConstraint':
157157
self._config.__enter__()
158158
returnself
159159

160-
def__exit__(self,exception_type,exception_value,traceback):
160+
def__exit__(self,exception_type:str,exception_value:str,traceback:str)->None:
161161
self._config.__exit__(exception_type,exception_value,traceback)
162162

163163

@@ -336,10 +336,10 @@ def __enter__(self):
336336
self._acquire_lock()
337337
returnself
338338

339-
def__exit__(self,exception_type,exception_value,traceback):
339+
def__exit__(self,exception_type,exception_value,traceback)->None:
340340
self.release()
341341

342-
defrelease(self):
342+
defrelease(self)->None:
343343
"""Flush changes and release the configuration write lock. This instance must not be used anymore afterwards.
344344
In Python 3, it's required to explicitly release locks and flush changes, as __del__ is not called
345345
deterministically anymore."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp