Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/QA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.14"
python-version: "3.15"
architecture: x64

- name: Install dependencies (and project)
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [macos-15, macos-26, macos-15-intel, macos-26-intel, windows-2022, windows-2025, ubuntu-22.04, ubuntu-24.04, ubuntu-26.04]
python: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"]
python: ["3.11", "3.12", "3.13", "3.14", "3.14t", "3.15", "3.15t"]

steps:
- uses: actions/checkout@v7
Expand All @@ -43,22 +43,22 @@ jobs:
run: inv coverage --args "-vvv"

- name: Upload coverage report to codecov
if: matrix.os == 'ubuntu-26.04' && matrix.python == '3.14'
if: matrix.os == 'ubuntu-26.04' && matrix.python == '3.15'
uses: codecov/codecov-action@v7
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

build-docs: # validate that doc can be built
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04

steps:
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.13"
python-version: "3.14"

- name: Install dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
version: 2

build:
os: ubuntu-24.04
os: ubuntu-26.04
tools:
python: '3.13'
python: '3.14'

# custom commands to run mkdocs build within hatch, as suggested by maintainer in
# https://github.com/readthedocs/readthedocs.org/issues/10706
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Breaking**: `Search.getResults()` renamed `Search.get_results()` (#200)
- **Breaking**: `SuggestionSearch.getEstimatedMatches()` renamed `SuggestionSearch.get_estimated_matches()` (#200)
- **Breaking**: `SuggestionSearch.getResults()` renamed `SuggestionSearch.get_results()` (#200)
- Modernize type hints in `libzim.pyx` to use PEP 604/585 syntax (e.g. `str | bytes`, `dict[...]`) instead of `typing.Union`/`typing.Dict`/etc. (#281)

### Removed

- **Breaking**: `Creator.add_metadata` no longer auto-converts a `Date` metadata value passed as `datetime.date`/`datetime.datetime`; pass pre-formatted `str`/`bytes` instead (#188)
- **Breaking**: Drop support for Python 3.10 (#281)

### Fixed

Expand All @@ -30,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add a CI job building the documentation on every PR/push so this kind of breakage is caught automatically (#279)
- Add support for Python 3.15 (#281)

## [3.13.1] - 2026-10-05

Expand Down
25 changes: 13 additions & 12 deletions libzim/libzim.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ import sys
import traceback
import warnings
from collections import OrderedDict
from collections.abc import Generator, Iterator
from types import ModuleType
from typing import Dict, Generator, Iterator, List, Optional, Set, TextIO, Tuple, Union
from typing import TextIO
from uuid import UUID

from cpython.buffer cimport PyBUF_WRITABLE
Expand Down Expand Up @@ -223,7 +224,7 @@ cdef class WritingBlob:
cdef zim.Blob c_blob
cdef bytes ref_content

def __cinit__(self, content: Union[str, bytes]):
def __cinit__(self, content: str | bytes):
if isinstance(content, str):
self.ref_content = content.encode('UTF-8')
else:
Expand Down Expand Up @@ -346,7 +347,7 @@ class BaseWritingItem:
"""
raise NotImplementedError("get_contentprovider must be implemented.")

def get_hints(self) -> Dict[Hint, pyint]:
def get_hints(self) -> dict[Hint, pyint]:
"""Get the Hints that help the Creator decide how to handle this item.

Hints affects compression, presence in suggestion, random and search.
Expand Down Expand Up @@ -540,7 +541,7 @@ cdef class _Creator:
with nogil:
self.c_creator.addMetadata(_name, _content, _mimetype)

def add_redirection(self, str path: str, str title: str, str target_path: str, dict hints: Dict[Hint, pyint]):
def add_redirection(self, str path: str, str title: str, str target_path: str, dict hints: dict[Hint, pyint]):
"""Add redirection entry to the archive.

Refer to https://wiki.openzim.org/wiki/ZIM_file_format#Redirect_Entry for more details.
Expand All @@ -565,7 +566,7 @@ cdef class _Creator:
with nogil:
self.c_creator.addRedirection(_path, _title, _targetPath, _hints)

def add_alias(self, str path: str, str title: str, str target_path: str, dict hints: Dict[Hint, pyint]):
def add_alias(self, str path: str, str title: str, str target_path: str, dict hints: dict[Hint, pyint]):
"""Alias the (existing) entry `target_path` as a new entry `path`.

Args:
Expand Down Expand Up @@ -615,7 +616,7 @@ class StringProvider(ContentProvider):
"""ContentProvider for a single encoded-or-not UTF-8 string."""

__module__ = writer_module_name
def __init__(self, content: Union[str, bytes]):
def __init__(self, content: str | bytes):
super().__init__()
self.content = content.encode("UTF-8") if isinstance(content, str) else content

Expand All @@ -630,7 +631,7 @@ class FileProvider(ContentProvider):
"""ContentProvider for a file using its local path."""

__module__ = writer_module_name
def __init__(self, filepath: Union[pathlib.Path, str]):
def __init__(self, filepath: pathlib.Path | str):
super().__init__()
self.filepath = filepath
self.size = os.path.getsize(self.filepath)
Expand Down Expand Up @@ -698,7 +699,7 @@ class IndexData:

raise NotImplementedError("get_wordcount must be implemented.")

def get_geoposition(self) -> Optional[Tuple[float, float]]:
def get_geoposition(self) -> tuple[float, float] | None:
"""GeoPosition used to index the item.

Returns:
Expand All @@ -711,13 +712,13 @@ class IndexData:
class Creator(_Creator):
"""Creator to create ZIM files."""
__module__ = writer_module_name
def config_compression(self, compression: Union[Compression, str]):
def config_compression(self, compression: Compression | str):
if not isinstance(compression, Compression):
compression = getattr(Compression, compression.lower())
return super().config_compression(compression)

def add_metadata(
self, name: str, content: Union[str, bytes],
self, name: str, content: str | bytes,
mimetype: str = "text/plain;charset=UTF-8"
):
if isinstance(content, str):
Expand Down Expand Up @@ -1116,7 +1117,7 @@ cdef class Archive:
return Entry.from_entry(move(entry))

@property
def metadata_keys(self) -> List[str]:
def metadata_keys(self) -> list[str]:
"""List of Metadata keys present in this archive.

Returns:
Expand Down Expand Up @@ -1301,7 +1302,7 @@ cdef class Archive:
"""
return self.c_archive.getMediaCount()

def get_illustration_sizes(self) -> Set[pyint]:
def get_illustration_sizes(self) -> set[pyint]:
"""Sizes for which an illustration is available (@1 scale only).

.. deprecated:: 3.8.0
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "libzim"
version = "4.0.0-dev0"
requires-python = ">=3.10,<3.15"
requires-python = ">=3.11,<3.16"
description = "A python-facing API for creating and interacting with ZIM files"
authors = [
{name = "openZIM", email = "dev@kiwix.org"},
Expand All @@ -30,11 +30,11 @@ classifiers = [
"Intended Audience :: Developers",
"Programming Language :: Cython",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Typing :: Stubs Only",
"Operating System :: MacOS",
"Operating System :: POSIX",
Expand Down Expand Up @@ -165,7 +165,7 @@ features = ["scripts", "test"]
PROFILE = "1"

[[tool.hatch.envs.test.matrix]]
python = ["3.10", "3.11", "3.12", "3.13", "3.14"]
python = ["3.11", "3.12", "3.13", "3.14", "3.15"]

[tool.hatch.envs.test.scripts]
run = "inv test --args '{args}'"
Expand Down Expand Up @@ -203,10 +203,10 @@ all = "inv checkall --args '{args}'"

[tool.black]
line-length = 88
target-version = ['py314']
target-version = ['py315']

[tool.ruff]
target-version = "py314"
target-version = "py315"
line-length = 88
src = ["src"]

Expand Down Expand Up @@ -333,6 +333,6 @@ exclude_lines = [
[tool.pyright]
include = ["libzim", "tests", "tasks.py"]
exclude = [".env/**", ".venv/**"]
pythonVersion = "3.14"
pythonVersion = "3.15"
typeCheckingMode="basic"
disableBytesTypePromotions = true
Loading