Skip to content

Commit dbd7e16

Browse files
authored
Merge pull request #303 from openzim/bootstrap_2
Adopt Python bootstrap 2.0.0
2 parents 8c85546 + 5ac4834 commit dbd7e16

24 files changed

Lines changed: 121 additions & 141 deletions

.github/workflows/QA.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ jobs:
6262
- name: Install dependencies (and project)
6363
run: |
6464
pip install -U pip
65-
pip install -e .[lint,scripts,test,check]
65+
pip install -e .[qa,scripts,test]
6666
67-
- name: Check black formatting
68-
run: inv lint-black
67+
- name: Check Linting
68+
run: inv check-lint
6969

70-
- name: Check ruff
71-
run: inv lint-ruff
70+
- name: Check Formatting
71+
run: inv check-format
7272

73-
- name: Check pyright
74-
run: inv check-pyright
73+
- name: Check Type
74+
run: inv check-type
7575

7676
check-javascript-qa:
7777
runs-on: ubuntu-24.04

.github/workflows/Tests.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@ jobs:
133133
python-version-file: pyproject.toml
134134
architecture: x64
135135

136-
- name: Install dependencies (and project)
136+
- name: Install dependencies
137137
run: |
138138
pip install -U pip hatch
139-
pip install -e .[docs]
140139
141140
- name: Build mkdoc documentation
142141
run: hatch run docs:build

.pre-commit-config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ repos:
77
hooks:
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
10-
- repo: https://github.com/psf/black
11-
rev: '25.11.0'
12-
hooks:
13-
- id: black
1410
- repo: https://github.com/astral-sh/ruff-pre-commit
15-
rev: v0.14.5
11+
rev: v0.15.12
1612
hooks:
17-
- id: ruff
13+
- id: ruff-check
14+
- id: ruff-format
1815
- repo: https://github.com/RobertCraigie/pyright-python
1916
rev: v1.1.407
2017
hooks:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
### Changed
2727

2828
- Upgrade to wombat 3.10.3 (#286)
29+
- Adopt openzim/\_python-bootstrap 2.0.0 (#303)
2930

3031
## [5.3.0] - 2025-11-14
3132

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# zimscraperlib
22

3-
[![QA Status](https://github.com/openzim/python-scraperlib/workflows/QA/badge.svg?query=branch%3Amain)](https://github.com/openzim/python-scraperlib/actions/workflows/QA.yaml)
4-
[![Tests Status](https://github.com/openzim/python-scraperlib/workflows/Tests/badge.svg?query=branch%3Amain)](https://github.com/openzim/python-scraperlib/actions/workflows/Tests.yaml)
3+
[![QA Status](https://github.com/openzim/python-scraperlib/actions/workflows/QA.yaml/badge.svg?branch=main)](https://github.com/openzim/python-scraperlib/actions/workflows/QA.yaml)
4+
[![Tests Status](https://github.com/openzim/python-scraperlib/actions/workflows/Tests.yaml/badge.svg?branch=main)](https://github.com/openzim/python-scraperlib/actions/workflows/Tests.yaml)
55
[![CodeFactor](https://www.codefactor.io/repository/github/openzim/python-scraperlib/badge)](https://www.codefactor.io/repository/github/openzim/python-scraperlib)
66
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
77
[![PyPI version shields.io](https://img.shields.io/pypi/v/zimscraperlib.svg)](https://pypi.org/project/zimscraperlib/)
@@ -67,7 +67,7 @@ apk add ffmpeg gifsicle libmagic wget cairo
6767

6868
This project adheres to openZIM's [Contribution Guidelines](https://github.com/openzim/overview/wiki/Contributing).
6969

70-
This project has implemented openZIM's [Python bootstrap, conventions and policies](https://github.com/openzim/_python-bootstrap/docs/Policy.md) **v1.0.2**.
70+
This project has implemented openZIM's [Python bootstrap, conventions and policies](https://github.com/openzim/_python-bootstrap/docs/Policy.md) **v2.0.0**.
7171

7272
All instructions below must be run from the root of your local clone of this repository.
7373

pyproject.toml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ scripts = [
5757
"PyYAML==6.0.3",
5858

5959
]
60-
lint = [
61-
"black==25.11.0",
62-
"ruff==0.14.5",
63-
]
64-
check = [
60+
qa = [
61+
"ruff==0.15.12",
6562
"pyright==1.1.407",
6663
"pytest==9.0.1",
6764
]
@@ -71,6 +68,7 @@ test = [
7168
"coverage==7.11.3",
7269
]
7370
docs = [
71+
"ruff==0.15.12",
7472
"mkdocs==1.6.1",
7573
"mkdocs-include-markdown-plugin==7.2.0",
7674
"mkdocs-material==9.7.0",
@@ -84,9 +82,8 @@ dev = [
8482
"ipython==9.7.0",
8583
"pre-commit==4.4.0",
8684
"zimscraperlib[scripts]",
87-
"zimscraperlib[lint]",
85+
"zimscraperlib[qa]",
8886
"zimscraperlib[test]",
89-
"zimscraperlib[check]",
9087
"zimscraperlib[docs]",
9188
]
9289

@@ -129,25 +126,19 @@ report-cov = "inv report-cov"
129126
coverage = "inv coverage --args '{args}'"
130127
html = "inv coverage --html --args '{args}'"
131128

132-
[tool.hatch.envs.lint]
133-
template = "lint"
129+
[tool.hatch.envs.qa]
130+
template = "qa"
134131
skip-install = false
135-
features = ["scripts", "lint"]
136-
137-
[tool.hatch.envs.lint.scripts]
138-
black = "inv lint-black --args '{args}'"
139-
ruff = "inv lint-ruff --args '{args}'"
140-
all = "inv lintall --args '{args}'"
141-
fix-black = "inv fix-black --args '{args}'"
142-
fix-ruff = "inv fix-ruff --args '{args}'"
143-
fixall = "inv fixall --args '{args}'"
144-
145-
[tool.hatch.envs.check]
146-
features = ["scripts", "check"]
132+
features = ["scripts", "qa", "test"]
147133

148-
[tool.hatch.envs.check.scripts]
149-
pyright = "inv check-pyright --args '{args}'"
150-
all = "inv checkall --args '{args}'"
134+
[tool.hatch.envs.qa.scripts]
135+
check-lint = "inv check-lint --args '{args}'"
136+
check-format = "inv check-format --args '{args}'"
137+
check-type = "inv check-type --args '{args}'"
138+
check-all = "inv check-all --args '{args}'"
139+
fix-format = "inv fix-format --args '{args}'"
140+
fix-lint = "inv fix-lint --args '{args}'"
141+
fix-all = "inv fix-all --args '{args}'"
151142

152143
[tool.hatch.envs.docs]
153144
features = ["scripts", "docs"]

src/zimscraperlib/html.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ def find_language_in(content: str | BinaryIO | TextIO, mime_type: str) -> str:
4040
node = soup.find(nodename)
4141
if node:
4242
if not isinstance(
43-
node, element.Tag # pyright:ignore[reportUnnecessaryIsInstance]
43+
node,
44+
element.Tag, # pyright:ignore[reportUnnecessaryIsInstance]
4445
) or not node.has_attr(key):
4546
continue
4647
if (
4748
nodename == "meta"
48-
and not node.attrs.get(
49-
"http-equiv", ""
50-
).lower() # pyright:ignore[reportUnknownMemberType, reportAttributeAccessIssue]
49+
and not node.attrs.get("http-equiv", "").lower() # pyright:ignore[reportUnknownMemberType, reportAttributeAccessIssue]
5150
== "content-language"
5251
):
5352
continue

src/zimscraperlib/i18n.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ def __eq__(self, value: object) -> bool:
167167

168168
def __hash__(self):
169169
return hash(
170-
f"{getattr(self, "iso_639_1", None)}$"
171-
f"{getattr(self, "iso_639_2b", None)}$"
172-
f"{getattr(self, "iso_639_2t", None)}$"
173-
f"{getattr(self, "iso_639_3", None)}$"
174-
f"{getattr(self, "iso_639_5", None)}$"
175-
f"{getattr(self, "english", None)}$"
176-
f"{getattr(self, "native", None)}"
170+
f"{getattr(self, 'iso_639_1', None)}$"
171+
f"{getattr(self, 'iso_639_2b', None)}$"
172+
f"{getattr(self, 'iso_639_2t', None)}$"
173+
f"{getattr(self, 'iso_639_3', None)}$"
174+
f"{getattr(self, 'iso_639_5', None)}$"
175+
f"{getattr(self, 'english', None)}$"
176+
f"{getattr(self, 'native', None)}"
177177
)
178178

179179

src/zimscraperlib/image/probing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def solarize(r: int, g: int, b: int) -> tuple[int, int, int]:
5050
sr, sg, sb = solarize(mr, mg, mb) # pyright: ignore[reportUnknownArgumentType]
5151

5252
return rgb_to_hex(
53-
mr, mg, mb # pyright: ignore[reportUnknownArgumentType]
53+
mr, # pyright: ignore[reportUnknownArgumentType]
54+
mg, # pyright: ignore[reportUnknownArgumentType]
55+
mb, # pyright: ignore[reportUnknownArgumentType]
5456
), rgb_to_hex(sr, sg, sb)
5557

5658

src/zimscraperlib/misc.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
"""Miscelaneous utils"""
22

3-
from typing import TypeVar
43

5-
T = TypeVar("T")
6-
7-
8-
def first(*args: T | None, default: T = "") -> T:
4+
def first[T](*args: T | None, default: T = "") -> T:
95
"""Return the first non-None value from *args; fallback to an empty string."""
106
return next((item for item in args if item is not None), default)

0 commit comments

Comments
 (0)