Skip to content

Commit c830743

Browse files
author
rgaudin
authored
Merge pull request #120 from openzim/clean_up
Clean up
2 parents c89b010 + 1099668 commit c830743

File tree

15 files changed

+216
-153
lines changed

15 files changed

+216
-153
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 88

.github/workflows/test.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ env:
55
LIBZIM_VERSION: 2021-10-05
66
LIBZIM_INCLUDE_PATH: include/zim
77
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8-
MAX_LINE_LENGTH: 88
98
PROFILE: 1
109

1110
jobs:
@@ -20,18 +19,11 @@ jobs:
2019
python-version: 3.6
2120
architecture: x64
2221

23-
- name: Autoformat with black
22+
- name: Check formatting and linting
2423
run: |
25-
pip install black
26-
black --check .
27-
28-
- name: Lint with flake8
29-
run: |
30-
pip install flake8
31-
# one pass for show-stopper syntax errors or undefined names
32-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
33-
# one pass for small stylistic things
34-
flake8 . --count --max-line-length=$MAX_LINE_LENGTH --statistics
24+
pip install -U invoke
25+
invoke install-dev
26+
invoke check
3527
3628
test:
3729
runs-on: ${{ matrix.os }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ __pycache__
88
.tox
99
.coverage
1010
coverage.*
11+
*.swp
12+
1113

1214
# Compiled binaries and package builds
1315
*.so

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ pipenv run pip install -e .
3030
### Run Linters & Tests
3131

3232
```bash
33-
# Autoformat code with black
34-
black --exclude=setup.py .
35-
# Lint and check for errors with flake8
36-
flake8 --exclude=setup.py .
33+
# Check format and linting
34+
invoke check
35+
# Autoformat and import sorting
36+
invoke lint
3737
# Typecheck with mypy (optional)
3838
mypy .
3939
# Run tests
40-
pytest .
40+
invoke test
4141
```
4242

4343
### Rebuild Cython extension during development

examples/basic_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import uuid
2121

2222
from libzim.reader import Archive
23-
from libzim.writer import Item, StringProvider, Creator
23+
from libzim.writer import Creator, Item, StringProvider
2424

2525

2626
class TestItem(Item):

libzim/libzim.pyx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,28 @@ __path__ = []
3131

3232
cimport zim
3333

34-
import os
34+
import datetime
3535
import enum
36+
import importlib
37+
import importlib.abc
38+
import os
39+
import pathlib
40+
import sys
41+
import traceback
42+
from types import ModuleType
43+
from typing import Dict, Generator, Iterator, List, Set, Union
3644
from uuid import UUID
37-
from cpython.ref cimport PyObject
45+
3846
from cpython.buffer cimport PyBUF_WRITABLE
47+
from cpython.ref cimport PyObject
3948
from cython.operator import preincrement
4049
from libc.stdint cimport uint64_t
41-
from libcpp.string cimport string
4250
from libcpp cimport bool
43-
from libcpp.memory cimport shared_ptr
4451
from libcpp.map cimport map
52+
from libcpp.memory cimport shared_ptr
53+
from libcpp.string cimport string
4554
from libcpp.utility cimport move
4655

47-
from typing import Dict, Union, Generator, List, Set, Iterator
48-
import datetime
49-
import pathlib
50-
import traceback
51-
from types import ModuleType
52-
import sys
53-
import importlib.abc
54-
5556
pybool = type(True)
5657
pyint = type(1)
5758

libzim/zim.pxd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919

2020
from cpython.ref cimport PyObject
21-
2221
from libc.stdint cimport uint32_t, uint64_t
2322
from libcpp cimport bool
23+
from libcpp.map cimport map
2424
from libcpp.memory cimport shared_ptr
2525
from libcpp.string cimport string
2626
from libcpp.vector cimport vector
27-
from libcpp.map cimport map
2827

2928

3029
cdef extern from "zim/zim.h" namespace "zim":

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[tool.black]
66
target-version = ['py36', 'py37', 'py38']
7+
8+
9+
[tool.pytest.ini_options]
10+
testpaths = ["tests"]

rebuild.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

requirements-dev.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
isort>=5.9,<6.0
2+
black>=21.9b0,<22.0
3+
flake8>=3.9,<4.0
4+
invoke>=1.5,<2.0
5+
coverage>=5.0,<7.0
6+
pytest>=6.2,<7.0
7+
pytest-cov>=2.10,<4.0
8+
Cython>=0.29.24

0 commit comments

Comments
 (0)