Skip to content

Commit c314a77

Browse files
committed
Small enhancements following review
1 parent e0f94d0 commit c314a77

6 files changed

Lines changed: 17 additions & 19 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ exclude_lines = [
279279
"if __name__ == .__main__.:",
280280
"if TYPE_CHECKING:",
281281
"class .*Protocol.*",
282+
"@abstractmethod",
282283
]
283284

284285
[tool.pyright]
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# flake8: noqa
2-
from .conversion import convert_image
3-
from .optimization import optimize_image
4-
from .probing import is_valid_image
5-
from .transformation import resize_image
1+
from zimscraperlib.image.conversion import convert_image
2+
from zimscraperlib.image.optimization import optimize_image
3+
from zimscraperlib.image.probing import is_valid_image
4+
from zimscraperlib.image.transformation import resize_image
65

76
__all__ = ["convert_image", "is_valid_image", "optimize_image", "resize_image"]
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from .config import Config
1+
from zimscraperlib.video.config import Config
2+
from zimscraperlib.video.encoding import reencode
3+
from zimscraperlib.video.probing import get_media_info
24

3-
# flake8: noqa
4-
from .encoding import reencode
5-
from .probing import get_media_info
6-
7-
__all__ = ["Config", "reencode", "get_media_info"]
5+
__all__ = ["Config", "get_media_info", "reencode"]

src/zimscraperlib/video/probing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import subprocess
33

44

5-
def get_media_info(src_path: str | pathlib.Path):
5+
def get_media_info(src_path: pathlib.Path):
66
"""dict of file's details from ffprobe
77
88
codecs: list of codecs in use

src/zimscraperlib/zim/metadata.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ def validate(self) -> None:
148148
_ = self.libzim_value
149149

150150
@abstractmethod
151-
def get_cleaned_value(self, value: Any) -> T: ... # pragma: no cover
151+
def get_cleaned_value(self, value: Any) -> T: ...
152152

153153
@property
154154
def libzim_value(self) -> bytes:
155155
return self.get_libzim_value()
156156

157157
@abstractmethod
158-
def get_libzim_value(self) -> bytes: ... # pragma: no cover
158+
def get_libzim_value(self) -> bytes: ...
159159

160160

161161
# Alias for convenience when function accept any metadata
@@ -236,12 +236,12 @@ def get_binary_from(
236236
elif isinstance(value, bytes):
237237
bvalue = value
238238
else:
239-
last_pos: int
239+
last_pos: int = 0
240240
if isinstance(value, SupportsSeekableRead) and value.seekable():
241241
last_pos = value.tell()
242242
bvalue = value.read()
243243
if isinstance(value, SupportsSeekableRead) and value.seekable():
244-
value.seek(last_pos) # pyright: ignore[reportPossiblyUnboundVariable]
244+
value.seek(last_pos)
245245
if not self.empty_allowed and not value:
246246
raise ValueError("Missing value (empty not allowed)")
247247
return bvalue
@@ -495,8 +495,8 @@ def get_reserved_names(cls) -> list[str]:
495495
for field in fields(cls):
496496
if not isinstance(field.type, type):
497497
continue
498-
# if field type is a type, it means that it is required (otherwise field
499-
# type is a string when None is allowed)
498+
# field.type is a `type` only when expecting a single type
499+
# and is a string in case of None Union
500500
names.append(getattr(field.type, "meta_name", ""))
501501
return names
502502

tests/filesystem/test_filesystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_content_mimetype_fallback(
3333
assert get_content_mimetype(undecodable_byte_stream) == "application/octet-stream"
3434

3535
# mock then so we keep coverage on systems where magic works
36-
def raising_magic(*_: Any, **__: Any):
36+
def raising_magic(*args: Any, **kwargs: Any): # noqa: ARG001
3737
raise UnicodeDecodeError("nocodec", b"", 0, 1, "noreason")
3838

3939
monkeypatch.setattr(magic, "from_buffer", raising_magic)

0 commit comments

Comments
 (0)