@@ -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- if not isinstance (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+ if isinstance (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 return self
353354
@@ -377,11 +378,11 @@ def release(self) -> None:
377378 if self ._lock is not None :
378379 self ._lock ._release_lock ()
379380
380- def optionxform (self , optionstr ) :
381+ def optionxform (self , optionstr : str ) -> str :
381382 """Do not transform options in any way when writing"""
382383 return optionstr
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- def string_decode (v ) :
401+ def string_decode (v : str ) -> str :
401402 if v [- 1 ] == '\\ ' :
402403 v = v [:- 1 ]
403404 # end cut trailing escapes to prevent decode error
@@ -479,11 +480,12 @@ def string_decode(v):
479480 if e :
480481 raise e
481482
482- def _has_includes (self ):
483+ def _has_includes (self ) -> Union [ bool , int ] :
483484 return self ._merge_includes and len (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- if fnmatch .fnmatchcase (self ._repo .git_dir , value ):
521- paths += self .items (section )
521+ if self . _repo . git_dir :
522+ if fnmatch .fnmatchcase (str ( self ._repo .git_dir ) , value ):
523+ paths += self .items (section )
522524
523525 elif keyword == "onbranch" :
524526 try :
0 commit comments