Skip to content

Commit 3af1228

Browse files
authored
Merge pull request #263 from openzim/upgrade-wombat
Upgrade Wombat.JS to 3.9.1 and other Python dependencies, fix recent changes
2 parents cc017df + e902a25 commit 3af1228

File tree

16 files changed

+75
-70
lines changed

16 files changed

+75
-70
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ repos:
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
1010
- repo: https://github.com/psf/black
11-
rev: '25.1.0'
11+
rev: '25.9.0'
1212
hooks:
1313
- id: black
1414
- repo: https://github.com/astral-sh/ruff-pre-commit
15-
rev: v0.11.8
15+
rev: v0.13.1
1616
hooks:
1717
- id: ruff
1818
- repo: https://github.com/RobertCraigie/pyright-python
19-
rev: v1.1.400
19+
rev: v1.1.405
2020
hooks:
2121
- id: pyright
2222
name: pyright (system)

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### Added
10+
### Added
1111

1212
- New `zim.dedup.Deduplicator` class to handle automatic deduplication of content before adding to the ZIM (#33)
1313

1414
### Changed
1515

16-
- Upgrade dependencies, especially wombat 3.8.12 (#262)
16+
- Upgrade dependencies, especially wombat 3.9.1 (#262, #263)
1717
- Backport changes in wabac.js around JS rewriting rules (#259)
1818

1919
### Fixed
2020

2121
- JS rewriting abusively rewrite import function (#255)
22+
- Test about badly escaped src in HTML is failing (#264)
2223

2324
### Added
2425

openzim.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ execute_after=[
66

77
[files.assets.actions."wombat.js"]
88
action="get_file"
9-
source="https://cdn.jsdelivr.net/npm/@webrecorder/wombat@3.8.12/dist/wombat.js"
9+
source="https://cdn.jsdelivr.net/npm/@webrecorder/wombat@3.9.1/dist/wombat.js"
1010
target_file="wombat.js"

pyproject.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ dependencies = [
1818
"python-magic>=0.4.3,<0.5",
1919
"libzim>=3.4.0,<4.0",
2020
"beautifulsoup4>=4.9.3,<5.0",
21-
"lxml>=4.6.3,<6.0",
21+
"lxml>=4.6.3,<7.0",
2222
"optimize-images>=1.3.6,<2.0",
2323
# regex has no upper-bound due to "date-based" release numbers, no semver, so their
2424
# promise is that they will never (or always) break the API, and the API is very
2525
# limited and we use only a very small subset of it.
2626
"regex>=2020.7.14",
2727
"pymupdf>=1.24.0,<2.0",
2828
"CairoSVG>=2.2.0,<3.0",
29-
"beartype>=0.19,<0.21",
29+
"beartype>=0.19,<0.22",
3030
# youtube-dl should be updated as frequently as possible
3131
"yt-dlp",
3232
"pillow>=7.0.0,<12.0",
33-
"urllib3>=1.26.5,<2.5.0",
33+
"urllib3>=1.26.5,<2.6.0",
3434
"piexif==1.1.3", # this dep is a nightmare in terms of release management, better pinned just like in optimize-images anyway
3535
"idna>=2.5,<4.0",
3636
"xxhash>=2.0,<4.0",
@@ -58,30 +58,30 @@ scripts = [
5858

5959
]
6060
lint = [
61-
"black==25.1.0",
62-
"ruff==0.11.8",
61+
"black==25.9.0",
62+
"ruff==0.13.1",
6363
]
6464
check = [
65-
"pyright==1.1.400",
66-
"pytest==8.3.5",
65+
"pyright==1.1.405",
66+
"pytest==8.4.2",
6767
]
6868
test = [
69-
"pytest==8.3.5",
70-
"pytest-mock==3.14.0",
71-
"coverage==7.8.0",
69+
"pytest==8.4.2",
70+
"pytest-mock==3.15.1",
71+
"coverage==7.10.7",
7272
]
7373
docs = [
7474
"mkdocs==1.6.1",
75-
"mkdocstrings[python]==0.29.1",
76-
"mkdocs-material==9.6.12",
77-
"pymdown-extensions==10.15",
75+
"mkdocs-include-markdown-plugin==7.1.7",
76+
"mkdocs-material==9.6.20",
77+
"mkdocstrings[python]==0.30.1",
78+
"pymdown-extensions==10.16.1",
7879
"mkdocs-gen-files==0.5.0",
7980
"mkdocs-literate-nav==0.6.2",
80-
"mkdocs-include-markdown-plugin==7.1.5",
8181
]
8282
dev = [
83-
"ipython==9.2.0",
84-
"pre-commit==4.2.0",
83+
"ipython==9.5.0",
84+
"pre-commit==4.3.0",
8585
"zimscraperlib[scripts]",
8686
"zimscraperlib[lint]",
8787
"zimscraperlib[test]",

src/zimscraperlib/download.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def shutdown(self) -> None:
3434
self.executor.shutdown(wait=True)
3535

3636
def _run_youtube_dl(self, url: str, options: dict[str, Any]) -> None:
37-
with youtube_dl.YoutubeDL(options) as ydl:
37+
with youtube_dl.YoutubeDL(
38+
options # pyright: ignore[reportArgumentType]
39+
) as ydl:
3840
ydl.download([url]) # pyright: ignore[reportUnknownMemberType]
3941

4042
def download(

src/zimscraperlib/i18n.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ def __eq__(self, value: object) -> bool:
164164
and self.native == getattr(value, "native", None)
165165
)
166166

167+
def __hash__(self):
168+
return hash(
169+
f"{getattr(self, "iso_639_1", None)}$"
170+
f"{getattr(self, "iso_639_2b", None)}$"
171+
f"{getattr(self, "iso_639_2t", None)}$"
172+
f"{getattr(self, "iso_639_3", None)}$"
173+
f"{getattr(self, "iso_639_5", None)}$"
174+
f"{getattr(self, "english", None)}$"
175+
f"{getattr(self, "native", None)}"
176+
)
177+
167178

168179
def find_language_names(query: str) -> tuple[str, str]:
169180
"""(native, english) language names for query"""

src/zimscraperlib/image/probing.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55

66
import colorthief # pyright: ignore[reportMissingTypeStubs]
77
import PIL.Image
8+
from PIL.Image import EXTENSION as PIL_FMT_EXTENSION
9+
from PIL.Image import init as init_pil
810

911
from zimscraperlib.filesystem import get_content_mimetype, get_file_mimetype
1012

13+
init_pil() # populate the PIL_FMT_EXTENSION dictionary
14+
15+
known_extensions = {".svg": "SVG"}
16+
known_extensions.update(PIL_FMT_EXTENSION)
17+
1118

1219
def get_colors(
1320
src: pathlib.Path, *, use_palette: bool | None = True
@@ -82,13 +89,6 @@ def format_for(
8289
"Cannot guess image format from file suffix when byte array is passed"
8390
)
8491

85-
from PIL.Image import EXTENSION as PIL_FMT_EXTENSION
86-
from PIL.Image import init as init_pil
87-
88-
init_pil() # populate the PIL_FMT_EXTENSION dictionary
89-
90-
known_extensions = {".svg": "SVG"}
91-
known_extensions.update(PIL_FMT_EXTENSION)
9292
return known_extensions[src.suffix] if src.suffix in known_extensions else None
9393

9494

src/zimscraperlib/inputs.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import shutil
33
import tempfile
44
from collections.abc import Iterable
5-
from typing import TypeVar
65

76
from zimscraperlib import logger
87
from zimscraperlib.constants import DEFAULT_USER_AGENT
@@ -14,8 +13,6 @@
1413
)
1514
from zimscraperlib.download import stream_file
1615

17-
T = TypeVar("T")
18-
1916

2017
def handle_user_provided_file(
2118
source: pathlib.Path | str | None = None,
@@ -136,6 +133,6 @@ def compute_tags(
136133
}
137134

138135

139-
def unique_values(items: list[T]) -> list[T]:
136+
def unique_values[T](items: list[T]) -> list[T]:
140137
"""Return unique values in input list while preserving list order"""
141138
return list(dict.fromkeys(items))

src/zimscraperlib/zim/creator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ def add_item_for(
381381
def add_item( # pyright: ignore[reportIncompatibleMethodOverride]
382382
self,
383383
item: libzim.writer.Item,
384+
*,
384385
duplicate_ok: bool | None = None,
385386
callbacks: list[Callback] | Callback | None = None,
386387
):
@@ -417,6 +418,7 @@ def add_redirect(
417418
path: str,
418419
target_path: str,
419420
title: str | None = "",
421+
*,
420422
is_front: bool | None = None,
421423
duplicate_ok: bool | None = None,
422424
):

src/zimscraperlib/zim/items.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def __init__(
235235
title: str | None = None,
236236
mimetype: str | None = None,
237237
hints: dict[libzim.writer.Hint, int] | None = None,
238+
*,
238239
use_disk: bool | None = None,
239240
**kwargs: Any,
240241
):

0 commit comments

Comments
 (0)