@@ -604,7 +604,7 @@ def read(self) -> None:
604
604
self ._merge_includes = False
605
605
# end
606
606
607
- def _write (self ,fp ) :
607
+ def _write (self ,fp : IO ) -> None :
608
608
"""Write an .ini-format representation of the configuration state in
609
609
git compatible format"""
610
610
def write_section (name ,section_dict ):
@@ -623,11 +623,11 @@ def write_section(name, section_dict):
623
623
for name ,value in self ._sections .items ():
624
624
write_section (name ,value )
625
625
626
- def items (self ,section_name ) :
626
+ def items (self ,section_name : str ) -> List [ Tuple [ str , str ]] :
627
627
""":return: list((option, value), ...) pairs of all items in the given section"""
628
628
return [(k ,v )for k ,v in super (GitConfigParser ,self ).items (section_name )if k != '__name__' ]
629
629
630
- def items_all (self ,section_name ) :
630
+ def items_all (self ,section_name : str ) -> List [ Tuple [ str , List [ str ]]] :
631
631
""":return: list((option, [values...]), ...) pairs of all items in the given section"""
632
632
rv = _OMD (self ._defaults )
633
633
@@ -644,7 +644,7 @@ def items_all(self, section_name):
644
644
return rv .items_all ()
645
645
646
646
@needs_values
647
- def write (self ):
647
+ def write (self )-> None :
648
648
"""Write changes to our file, if there are changes at all
649
649
650
650
:raise IOError: if this is a read-only writer instance or if we could not obtain
@@ -661,19 +661,21 @@ def write(self):
661
661
if self ._has_includes ():
662
662
log .debug ("Skipping write-back of configuration file as include files were merged in." +
663
663
"Set merge_includes=False to prevent this." )
664
- return
664
+ return None
665
665
# end
666
666
667
667
fp = self ._file_or_files
668
668
669
669
# we have a physical file on disk, so get a lock
670
670
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?
672
672
self ._lock ._obtain_lock ()
673
673
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 )
676
677
else :
678
+ fp = cast (IO ,fp )
677
679
fp .seek (0 )
678
680
# make sure we do not overwrite into an existing file
679
681
if hasattr (fp ,'truncate' ):