Skip to content

Commit 1cd0a7b

Browse files
committed
Fix more pyright errors
1 parent ff1b849 commit 1cd0a7b

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/tagstudio/qt/helpers/file_wrappers/archive/archive_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ def has_file_name(self, file_name: str) -> bool:
1717
raise NotImplementedError
1818

1919
@abstractmethod
20-
def read(self, file_name: str) -> bytes:
20+
def read(self, file_name: str) -> bytes | None:
2121
raise NotImplementedError

src/tagstudio/qt/helpers/file_wrappers/archive/seven_zip_file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Literal, Self
44

55
import py7zr
6+
from py7zr import io
67

78
from tagstudio.qt.helpers.file_wrappers.archive.archive_file import ArchiveFile
89

@@ -43,7 +44,7 @@ def read(self, file_name: str) -> bytes | None:
4344
# See https://py7zr.readthedocs.io/en/stable/api.html#py7zr.SevenZipFile.extract
4445
self.__seven_zip_file.reset()
4546

46-
factory = py7zr.io.BytesIOFactory(limit=10485760) # 10 MiB
47+
factory = io.BytesIOFactory(limit=10485760) # 10 MiB
4748

4849
search_paths: list[Path] = [Path(file_name), Path(self.path.name, file_name)]
4950
try:

src/tagstudio/qt/previews/renderers/ebook_renderer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ def _extract_cover(
103103
]
104104
page_name: str = pages[int(unwrap(cover.get("Image")))]
105105
if page_name.endswith((".png", ".jpg", ".jpeg", ".gif", ".bmp", ".svg")):
106-
image_data: bytes = archive.read(page_name)
106+
image_data: bytes | None = archive.read(page_name)
107+
if image_data is None:
108+
raise OSError
109+
107110
return Image.open(BytesIO(image_data))
108111

109112
return None

0 commit comments

Comments
 (0)