diff options
| author | Daniel Schadt <kingdread@gmx.de> | 2025-12-29 17:15:16 +0100 |
|---|---|---|
| committer | Daniel Schadt <kingdread@gmx.de> | 2025-12-29 17:15:16 +0100 |
| commit | 95e137f053caaa4c424915ef408cd2920dadc516 (patch) | |
| tree | 0ef629fb2bded42434b60de39d44023acb423bcf | |
| parent | a967b1103b4446528e641cf13c6986c542de56fd (diff) | |
| download | fietsboek-95e137f053caaa4c424915ef408cd2920dadc516.tar.gz fietsboek-95e137f053caaa4c424915ef408cd2920dadc516.tar.bz2 fietsboek-95e137f053caaa4c424915ef408cd2920dadc516.zip | |
fix types in fstrans
| -rw-r--r-- | fietsboek/fstrans.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fietsboek/fstrans.py b/fietsboek/fstrans.py index 13b0018..35cc992 100644 --- a/fietsboek/fstrans.py +++ b/fietsboek/fstrans.py @@ -68,7 +68,7 @@ import shutil import uuid from pathlib import Path -import transaction +import transaction # type: ignore from filelock import FileLock LOGGER = logging.getLogger(__name__) @@ -128,7 +128,7 @@ class WriteBytes(Action): def __init__(self, path: Path, data: bytes): self.path = path self.data = data - self.old = None + self.old: bytes | None = None def __repr__(self): return f"<WriteBytes {len(self.data)} to {self.path}>" @@ -152,7 +152,7 @@ class Unlink(Action): def __init__(self, path: Path): self.path = path - self.old = None + self.old: bytes | None = None def __repr__(self): return f"<Unlink {self.path}>" @@ -162,7 +162,10 @@ class Unlink(Action): self.path.unlink() def undo(self): - self.path.write_bytes(self.old) + # This should not happen, unless an exception occurs when we read the + # file + if self.old is not None: + self.path.write_bytes(self.old) class MakeDir(Action): @@ -171,7 +174,7 @@ class MakeDir(Action): def __init__(self, path: Path, exist_ok: bool = False): self.path = path self.exist_ok = exist_ok - self.existed = None + self.existed: bool | None = None def __repr__(self): return f"<MakeDir {self.path}>" |
