Skip to content

Commit e702630

Browse files
committed
ruff fixes
1 parent b72dcc0 commit e702630

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

mutablezip/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""mutable zip file"""
1+
"""mutable zip file."""
22

33
from __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")

tests/test_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from mutablezip import MutableZipFile
1515

1616

17-
def test_MutableZipFile():
17+
def test_MutableZipFile() -> None:
1818
with MutableZipFile(f"{THISDIR}/data/mutable.zip", "a", compression=ZIP_DEFLATED) as zipFile:
1919
with zipFile.open("foo.txt", "r") as file:
2020
lines = [line.strip() for line in file.readlines()]
@@ -24,7 +24,7 @@ def test_MutableZipFile():
2424
assert len(zipFile.namelist()) == 1
2525

2626

27-
def test_ZipFile():
27+
def test_ZipFile() -> None:
2828
with ZipFile(f"{THISDIR}/data/immutable.zip", "a", compression=ZIP_DEFLATED) as zipFile:
2929
with zipFile.open("foo.txt", "r") as file:
3030
lines = [line.strip() for line in file.readlines()]

0 commit comments

Comments
 (0)