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

Commit94b7ece

Browse files
committed
Add types to config.py GitConfigParser .release() ._read() ._has_includes() ._included_paths() .__del__() .__exit__() .__enter__() ._optionform()
1 parentefc2598 commit94b7ece

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

‎git/config.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,11 @@ def _acquire_lock(self) -> None:
330330
"Write-ConfigParsers can operate on a single file only, multiple files have been passed")
331331
# END single file check
332332

333-
ifnotisinstance(self._file_or_files, (str,Path)):# cannot narrow by os._pathlike until 3.5 dropped
334-
file_or_files=cast(IO,self._file_or_files).name# type: PathLike
335-
else:
333+
ifisinstance(self._file_or_files, (str,Path)):# cannot narrow by os._pathlike until 3.5 dropped
336334
file_or_files=self._file_or_files
335+
else:
336+
file_or_files=cast(IO,self._file_or_files).name
337+
337338
# END get filename from handle/stream
338339
# initialize lock base - we want to write
339340
self._lock=self.t_lock(file_or_files)
@@ -342,12 +343,12 @@ def _acquire_lock(self) -> None:
342343
self._lock._obtain_lock()
343344
# END read-only check
344345

345-
def__del__(self):
346+
def__del__(self)->None:
346347
"""Write pending changes if required and release locks"""
347348
# NOTE: only consistent in PY2
348349
self.release()
349350

350-
def__enter__(self):
351+
def__enter__(self)->'GitConfigParser':
351352
self._acquire_lock()
352353
returnself
353354

@@ -377,11 +378,11 @@ def release(self) -> None:
377378
ifself._lockisnotNone:
378379
self._lock._release_lock()
379380

380-
defoptionxform(self,optionstr):
381+
defoptionxform(self,optionstr:str)->str:
381382
"""Do not transform options in any way when writing"""
382383
returnoptionstr
383384

384-
def_read(self,fp,fpname):
385+
def_read(self,fp:IO[bytes],fpname:str)->None:
385386
"""A direct copy of the py2.4 version of the super class's _read method
386387
to assure it uses ordered dicts. Had to change one line to make it work.
387388
@@ -397,7 +398,7 @@ def _read(self, fp, fpname):
397398
is_multi_line=False
398399
e=None# None, or an exception
399400

400-
defstring_decode(v):
401+
defstring_decode(v:str)->str:
401402
ifv[-1]=='\\':
402403
v=v[:-1]
403404
# end cut trailing escapes to prevent decode error
@@ -479,11 +480,12 @@ def string_decode(v):
479480
ife:
480481
raisee
481482

482-
def_has_includes(self):
483+
def_has_includes(self)->Union[bool,int]:
483484
returnself._merge_includesandlen(self._included_paths())
484485

485-
def_included_paths(self):
486-
"""Return all paths that must be included to configuration.
486+
def_included_paths(self)->List[Tuple[str,str]]:
487+
"""Return List all paths that must be included to configuration
488+
as Tuples of (option, value).
487489
"""
488490
paths= []
489491

@@ -516,9 +518,9 @@ def _included_paths(self):
516518
),
517519
value
518520
)
519-
520-
iffnmatch.fnmatchcase(self._repo.git_dir,value):
521-
paths+=self.items(section)
521+
ifself._repo.git_dir:
522+
iffnmatch.fnmatchcase(str(self._repo.git_dir),value):
523+
paths+=self.items(section)
522524

523525
elifkeyword=="onbranch":
524526
try:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp