@@ -604,7 +604,7 @@ def read(self) -> None:
604604 self ._merge_includes = False
605605 # end
606606
607- def _write (self , fp ) :
607+ def _write (self , fp : IO ) -> None :
608608 """Write an .ini-format representation of the configuration state in
609609 git compatible format"""
610610 def write_section (name , section_dict ):
@@ -623,11 +623,11 @@ def write_section(name, section_dict):
623623 for name , value in self ._sections .items ():
624624 write_section (name , value )
625625
626- def items (self , section_name ) :
626+ def items (self , section_name : str ) -> List [ Tuple [ str , str ]] :
627627 """:return: list((option, value), ...) pairs of all items in the given section"""
628628 return [(k , v ) for k , v in super (GitConfigParser , self ).items (section_name ) if k != '__name__' ]
629629
630- def items_all (self , section_name ) :
630+ def items_all (self , section_name : str ) -> List [ Tuple [ str , List [ str ]]] :
631631 """:return: list((option, [values...]), ...) pairs of all items in the given section"""
632632 rv = _OMD (self ._defaults )
633633
@@ -644,7 +644,7 @@ def items_all(self, section_name):
644644 return rv .items_all ()
645645
646646 @needs_values
647- def write (self ):
647+ def write (self ) -> None :
648648 """Write changes to our file, if there are changes at all
649649
650650 :raise IOError: if this is a read-only writer instance or if we could not obtain
@@ -661,19 +661,21 @@ def write(self):
661661 if self ._has_includes ():
662662 log .debug ("Skipping write-back of configuration file as include files were merged in." +
663663 "Set merge_includes=False to prevent this." )
664- return
664+ return None
665665 # end
666666
667667 fp = self ._file_or_files
668668
669669 # we have a physical file on disk, so get a lock
670670 is_file_lock = isinstance (fp , (str , IOBase ))
671- if is_file_lock :
671+ if is_file_lock and self . _lock is not None : # else raise Error?
672672 self ._lock ._obtain_lock ()
673673 if not hasattr (fp , "seek" ):
674- with open (self ._file_or_files , "wb" ) as fp :
675- self ._write (fp )
674+ self ._file_or_files = cast (PathLike , self ._file_or_files )
675+ with open (self ._file_or_files , "wb" ) as fp_open :
676+ self ._write (fp_open )
676677 else :
678+ fp = cast (IO , fp )
677679 fp .seek (0 )
678680 # make sure we do not overwrite into an existing file
679681 if hasattr (fp , 'truncate' ):
0 commit comments