Skip to content

Commit 51bb1d2

Browse files
authored
Merge pull request #99 from FledgeXu/imporve
Better QA configuration
2 parents 9f0b3cb + 28ee9e3 commit 51bb1d2

File tree

10 files changed

+152
-18
lines changed

10 files changed

+152
-18
lines changed

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ jobs:
4949
python -m pip install --upgrade pip
5050
pip install -U tox
5151
- name: Run tox
52-
run: tox -e py38,black,coverage
52+
run: tox -e py38,black,isort,flake8,coverage
5353
env:
5454
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Diff for: .gitignore

+124-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/python,macos,windows,linux
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=python,macos,windows,linux
3+
4+
### Linux ###
5+
*~
6+
7+
# temporary files which can be created if a process still has a handle open of a deleted file
8+
.fuse_hidden*
9+
10+
# KDE directory preferences
11+
.directory
12+
13+
# Linux trash folder which might appear on any partition or disk
14+
.Trash-*
15+
16+
# .nfs files are created when an open file is removed but is still being accessed
17+
.nfs*
18+
19+
### macOS ###
20+
# General
21+
.DS_Store
22+
.AppleDouble
23+
.LSOverride
24+
25+
# Icon must end with two \r
26+
Icon
27+
28+
29+
# Thumbnails
30+
._*
31+
32+
# Files that might appear in the root of a volume
33+
.DocumentRevisions-V100
34+
.fseventsd
35+
.Spotlight-V100
36+
.TemporaryItems
37+
.Trashes
38+
.VolumeIcon.icns
39+
.com.apple.timemachine.donotpresent
40+
41+
# Directories potentially created on remote AFP share
42+
.AppleDB
43+
.AppleDesktop
44+
Network Trash Folder
45+
Temporary Items
46+
.apdisk
47+
48+
### macOS Patch ###
49+
# iCloud generated files
50+
*.icloud
51+
52+
### Python ###
153
# Byte-compiled / optimized / DLL files
254
__pycache__/
355
*.py[cod]
@@ -20,7 +72,6 @@ parts/
2072
sdist/
2173
var/
2274
wheels/
23-
pip-wheel-metadata/
2475
share/python-wheels/
2576
*.egg-info/
2677
.installed.cfg
@@ -50,6 +101,7 @@ coverage.xml
50101
*.py,cover
51102
.hypothesis/
52103
.pytest_cache/
104+
cover/
53105

54106
# Translations
55107
*.mo
@@ -72,6 +124,7 @@ instance/
72124
docs/_build/
73125

74126
# PyBuilder
127+
.pybuilder/
75128
target/
76129

77130
# Jupyter Notebook
@@ -82,7 +135,9 @@ profile_default/
82135
ipython_config.py
83136

84137
# pyenv
85-
.python-version
138+
# For a library or package, you might want to ignore these files since the code is
139+
# intended to run in multiple environments; otherwise, check them in:
140+
# .python-version
86141

87142
# pipenv
88143
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
@@ -91,7 +146,22 @@ ipython_config.py
91146
# install all needed dependencies.
92147
#Pipfile.lock
93148

94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
149+
# poetry
150+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
151+
# This is especially recommended for binary packages to ensure reproducibility, and is more
152+
# commonly ignored for libraries.
153+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
154+
#poetry.lock
155+
156+
# pdm
157+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
158+
#pdm.lock
159+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
160+
# in version control.
161+
# https://pdm.fming.dev/#use-with-ide
162+
.pdm.toml
163+
164+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
95165
__pypackages__/
96166

97167
# Celery stuff
@@ -127,3 +197,54 @@ dmypy.json
127197

128198
# Pyre type checker
129199
.pyre/
200+
201+
# pytype static type analyzer
202+
.pytype/
203+
204+
# Cython debug symbols
205+
cython_debug/
206+
207+
# PyCharm
208+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
209+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
210+
# and can be added to the global gitignore or merged into this file. For a more nuclear
211+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
212+
#.idea/
213+
214+
### Python Patch ###
215+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
216+
poetry.toml
217+
218+
# ruff
219+
.ruff_cache/
220+
221+
# LSP config files
222+
pyrightconfig.json
223+
224+
### Windows ###
225+
# Windows thumbnail cache files
226+
Thumbs.db
227+
Thumbs.db:encryptable
228+
ehthumbs.db
229+
ehthumbs_vista.db
230+
231+
# Dump file
232+
*.stackdump
233+
234+
# Folder config file
235+
[Dd]esktop.ini
236+
237+
# Recycle Bin used on file shares
238+
$RECYCLE.BIN/
239+
240+
# Windows Installer files
241+
*.cab
242+
*.msi
243+
*.msix
244+
*.msm
245+
*.msp
246+
247+
# Windows shortcuts
248+
*.lnk
249+
250+
# End of https://www.toptal.com/developers/gitignore/api/python,macos,windows,linux

Diff for: .pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v3.2.0
5+
rev: v4.4.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- repo: https://github.com/pycqa/isort
10-
rev: "5.9.3"
10+
rev: "5.12.0"
1111
hooks:
1212
- id: isort
1313
args: ["--profile", "black", "--filter-files"]
1414
- repo: https://github.com/psf/black
15-
rev: "22.3.0"
15+
rev: "23.1.0"
1616
hooks:
1717
- id: black
18-
- repo: https://gitlab.com/pycqa/flake8
19-
rev: "3.9.2"
18+
- repo: https://github.com/pycqa/flake8
19+
rev: "6.0.0"
2020
hooks:
2121
- id: flake8
2222
args: ["--max-line-length", "88", "--extend-ignore=E203"]

Diff for: README.md

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ sudo apt install libmagic1 wget ffmpeg \
4545
libharfbuzz-dev libfribidi-dev libxcb1-dev gifsicle
4646
```
4747

48+
# Contribution
49+
50+
```shell
51+
pip -r requirements.txt
52+
pip install tox pre-commit
53+
pre-commit install
54+
# For tests
55+
tox
56+
```
57+
4858
# Users
4959

5060
Non-exhaustive list of scrapers using it (check status when updating API):

Diff for: src/zimscraperlib/image/optimization.py

-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def optimize_png(
6161
background_color: Optional[Tuple[int, int, int]] = (255, 255, 255),
6262
**options,
6363
) -> Union[pathlib.Path, io.BytesIO]:
64-
6564
"""method to optimize PNG files using a pure python external optimizer
6665
6766
Arguments:
@@ -107,7 +106,6 @@ def optimize_jpeg(
107106
keep_exif: Optional[bool] = True,
108107
**options,
109108
) -> Union[pathlib.Path, io.BytesIO]:
110-
111109
"""method to optimize JPEG files using a pure python external optimizer
112110
quality: JPEG quality (integer between 1 and 100)
113111
values: 50 | 55 | 35 | 100 | XX
@@ -155,7 +153,6 @@ def optimize_jpeg(
155153
dst.seek(0)
156154

157155
if keep_exif and had_exif:
158-
159156
piexif.transplant(
160157
exif_src=str(src.resolve())
161158
if isinstance(src, pathlib.Path)

Diff for: tests/conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ def real_zim_file(tmpdir_factory):
174174

175175
@pytest.fixture(scope="session")
176176
def undecodable_byte_stream():
177-
178177
return (
179178
b"\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00"
180179
b"\x00\x00\x01\x00\xfb\xff~\x00\x08\x00\xfd\xff\x01\x00\x00\x00"

Diff for: tests/filesystem/test_filesystem.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def test_content_mimetype(png_image, jpg_image, undecodable_byte_stream):
2525

2626

2727
def test_content_mimetype_fallback(monkeypatch, undecodable_byte_stream):
28-
2928
# use raw function first to test actual code
3029
assert get_content_mimetype(undecodable_byte_stream) == "application/octet-stream"
3130

Diff for: tests/logging/test_logging.py

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def test_critical_level(random_id, console):
8080

8181

8282
def test_format():
83-
8483
# assert is_in_log(message, console)
8584
# "[%(asctime)s] %(levelname)s:%(message)s"
8685
pass

Diff for: tests/ogvjs/test_ogvjs.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
def prepare_ogvjs_folder(tmp_path, videojs_url, ogvjs_url, videojs_ogvjs_url):
16-
1716
videojs_zip = tmp_path / "video-js-7.6.4.zip"
1817
if not videojs_zip.exists():
1918
save_large_file(videojs_url, videojs_zip)

Diff for: tox.ini

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py36, py37, py38, py39, py310, py311, black, coverage
2+
envlist = py36, py37, py38, py39, py310, py311, black, isort, flake8, coverage
33

44
[testenv]
55
passenv =
@@ -15,9 +15,19 @@ commands =
1515

1616
[testenv:black]
1717
deps =
18-
black>=22.3.0,<23
18+
black>=23.1.0,<24
1919
commands = black --check .
2020

21+
[testenv:isort]
22+
deps =
23+
isort>=5.12.0,<5.13
24+
commands = isort --profile black --check src tests
25+
26+
[testenv:flake8]
27+
deps =
28+
flake8>=6.0.0,<7.0
29+
commands = flake8 src --count --max-line-length=88 --statistics --extend-ignore=E203
30+
2131
[testenv:coverage]
2232
passenv =
2333
CODECOV_TOKEN

0 commit comments

Comments
 (0)