1- """mutable zip file"""
1+ """mutable zip file. """
22
33from __future__ import annotations
44
@@ -16,19 +16,19 @@ class MutableZipFile(ZipFile):
1616 Add delete (via remove_file) and update (via writestr and write methods)
1717 To enable update features use MutableZipFile with the 'with statement',
1818 Upon __exit__ (if updates were applied) a new zip file will override the
19- exiting one with the updates
19+ exiting one with the updates.
2020 """
2121
2222 class DeleteMarker :
23- """delete marker"""
23+ """delete marker. """
2424
2525 def __init__ (
2626 self ,
2727 file : str | IO [bytes ],
2828 mode : Literal ["r" , "w" , "x" , "a" ] = "r" ,
2929 compression : int = ZIP_STORED ,
3030 allowZip64 : bool = False ,
31- ):
31+ ) -> None :
3232 super ().__init__ (file , mode = mode , compression = compression , allowZip64 = allowZip64 )
3333 # track file to override in zip
3434 self ._replace = {}
@@ -47,7 +47,7 @@ def writestr(
4747 data : bytes | str ,
4848 compress_type : int | None = None ,
4949 compresslevel : int | None = None ,
50- ):
50+ ) -> None :
5151 if isinstance (zinfo_or_arcname , ZipInfo ):
5252 name = zinfo_or_arcname .filename
5353 else :
@@ -76,7 +76,7 @@ def write(
7676 arcname : str | PathLike [str ] | None = None ,
7777 compress_type : int | None = None ,
7878 compresslevel : int | None = None ,
79- ):
79+ ) -> None :
8080 arcname = arcname or filename
8181 # If the file exits, and needs to be overridden,
8282 # mark the entry, and create a temp-file for it
@@ -115,17 +115,17 @@ def __exit__(
115115 self ._closeAllTempFiles ()
116116 self ._allowUpdates = False
117117
118- def _closeAllTempFiles (self ):
119- """Close all temporary files"""
118+ def _closeAllTempFiles (self ) -> None :
119+ """Close all temporary files. """
120120 for tempFile in self ._replace .values ():
121121 if hasattr (tempFile , "close" ):
122122 tempFile .close ()
123123
124- def removeFile (self , path : str | PathLike [str ]):
125- """Flag a file with a delete marker"""
124+ def removeFile (self , path : str | PathLike [str ]) -> None :
125+ """Flag a file with a delete marker. """
126126 self ._replace [path ] = self .DeleteMarker ()
127127
128- def _rebuildZip (self ):
128+ def _rebuildZip (self ) -> None :
129129 tempdir = mkdtemp ()
130130 try :
131131 tempZipPath = join (tempdir , "new.zip" )
0 commit comments