Skip to content

Commit

Permalink
Merge pull request #245 from openzim/python_3_13
Browse files Browse the repository at this point in the history
Upgrade to Python 3.13
  • Loading branch information
benoit74 authored Jan 20, 2025
2 parents 9550e4d + cf2cc44 commit c201e90
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
python -m build --sdist --wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
uses: pypa/gh-action-pypi-publish@release/v1.12
# OPTIONAL PUBLICATION TO NPM, NOT NEEDED BY SCRAPERS IN THE END

# publish-js:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: install ffmpeg and gifsicle
run: sudo apt update && sudo apt install ffmpeg gifsicle

- name: Set up Python 3.12
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.9.2
hooks:
- id: ruff
- repo: https://github.com/RobertCraigie/pyright-python
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 2
build:
os: ubuntu-24.04
tools:
python: '3.12'
python: '3.13'

# custom commands to run mkdocs build within hatch, as suggested by maintainer in
# https://github.com/readthedocs/readthedocs.org/issues/10706
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Upgrade to support only Python 3.13 (#203)

## [5.0.0] - 2025-01-14

This is a major release with a lot of breaking changes but most changes are easy to fix.
Expand Down
24 changes: 13 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[build-system]
# jinja2 is required to generate JS and Python rules at build time
# PyYAML is used to parse fuzzy rules and generate Python/JS code
requires = ["hatchling", "hatch-openzim>=0.2", "jinja2==3.1.4", "PyYAML==6.0.2"]
requires = ["hatchling", "hatch-openzim>=0.2", "jinja2==3.1.5", "PyYAML==6.0.2"]
build-backend = "hatchling.build"

[project]
name = "zimscraperlib"
requires-python = ">=3.12,<3.13"
requires-python = ">=3.13,<3.14"
description = "Collection of python tools to re-use common code across scrapers"
readme = "README.md"
dependencies = [
Expand Down Expand Up @@ -51,13 +51,13 @@ scripts = [
# jinja2 is required to generate JS and Python rules at build time
# PyYAML is used to parse fuzzy rules and generate Python/JS code
# also update version in build-system above and in build_js.sh
"jinja2==3.1.4",
"jinja2==3.1.5",
"PyYAML==6.0.2",

]
lint = [
"black==24.10.0",
"ruff==0.8.2",
"ruff==0.9.2",
]
check = [
"pyright==1.1.391",
Expand All @@ -66,19 +66,19 @@ check = [
test = [
"pytest==8.3.4",
"pytest-mock==3.14.0",
"coverage==7.6.9",
"coverage==7.6.10",
]
docs = [
"mkdocs==1.6.1",
"mkdocstrings[python]==0.27.0",
"mkdocs-material==9.5.44",
"pymdown-extensions==10.12",
"mkdocs-material==9.5.50",
"pymdown-extensions==10.14",
"mkdocs-gen-files==0.5.0",
"mkdocs-literate-nav==0.6.1",
"mkdocs-include-markdown-plugin==7.1.2",
]
dev = [
"ipython==8.30.0",
"ipython==8.31.0",
"pre-commit==4.0.1",
"zimscraperlib[scripts]",
"zimscraperlib[lint]",
Expand Down Expand Up @@ -155,10 +155,10 @@ build = "inv docs-build --args '{args}'"

[tool.black]
line-length = 88
target-version = ['py312']
target-version = ['py313']

[tool.ruff]
target-version = "py312"
target-version = "py313"
line-length = 88
src = ["src", "contrib"]

Expand Down Expand Up @@ -221,6 +221,8 @@ select = [
"YTT", # flake8-2020
]
ignore = [
# Allow to shadow Python standard-library modules
"A005",
# Allow non-abstract empty methods in abstract base classes
"B027",
# Remove flake8-errmsg since we consider they bloat the code and provide limited value
Expand Down Expand Up @@ -289,7 +291,7 @@ exclude_lines = [
include = ["contrib", "src", "tests", "tasks.py"]
exclude = [".env/**", ".venv/**"]
extraPaths = ["src"]
pythonVersion = "3.12"
pythonVersion = "3.13"
typeCheckingMode="strict"
disableBytesTypePromotions = true

Expand Down
2 changes: 1 addition & 1 deletion src/zimscraperlib/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.0.1-dev0"
__version__ = "5.1.0-dev0"
4 changes: 2 additions & 2 deletions src/zimscraperlib/zim/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
def get_size(self) -> int:
return getattr(self, "size", -1)

def gen_blob(self) -> Generator[libzim.writer.Blob, None, None]:
def gen_blob(self) -> Generator[libzim.writer.Blob]:
yield libzim.writer.Blob(self.fileobj.getvalue()) # pragma: no cover


Expand Down Expand Up @@ -88,7 +88,7 @@ def get_size_of(url: str) -> int | None:
def get_size(self) -> int:
return getattr(self, "size", -1)

def gen_blob(self) -> Generator[libzim.writer.Blob, None, None]: # pragma: no cover
def gen_blob(self) -> Generator[libzim.writer.Blob]: # pragma: no cover
for chunk in self.resp.iter_content(10 * 1024):
if chunk:
yield libzim.writer.Blob(chunk)
Expand Down
18 changes: 9 additions & 9 deletions tests/rewriting/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ def get_document_uri(


@pytest.fixture(scope="module")
def simple_url_rewriter_gen() -> (
Generator[Callable[[str], ArticleUrlRewriter], None, None]
):
def simple_url_rewriter_gen() -> Generator[Callable[[str], ArticleUrlRewriter]]:
"""Fixture to create a basic url rewriter returning URLs as-is"""

def get_simple_url_rewriter(url: str, suffix: str = "") -> ArticleUrlRewriter:
Expand All @@ -56,11 +54,13 @@ def get_simple_url_rewriter(url: str, suffix: str = "") -> ArticleUrlRewriter:


@pytest.fixture(scope="module")
def js_rewriter_gen() -> Generator[
Callable[[ArticleUrlRewriter, str | None, Callable[[ZimPath], None]], JsRewriter],
None,
None,
]:
def js_rewriter_gen() -> (
Generator[
Callable[
[ArticleUrlRewriter, str | None, Callable[[ZimPath], None]], JsRewriter
]
]
):
"""Fixture to create a basic url rewriter returning URLs as-is"""

def get_js_rewriter(
Expand All @@ -79,7 +79,7 @@ def get_js_rewriter(

@pytest.fixture(scope="module")
def css_rewriter_gen() -> (
Generator[Callable[[ArticleUrlRewriter, str | None], CssRewriter], None, None]
Generator[Callable[[ArticleUrlRewriter, str | None], CssRewriter]]
):
"""Fixture to create a basic url rewriter returning URLs as-is"""

Expand Down

0 comments on commit c201e90

Please sign in to comment.