Skip to content

Commit 31e8756

Browse files
committed
chore: Template upgrade
1 parent 0133369 commit 31e8756

12 files changed

Lines changed: 186 additions & 116 deletions

File tree

.copier-answers.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 0.2.1
3-
_src_path: gh:pawamoy/copier-poetry
2+
_commit: e9e472d
3+
_src_path: gh:pawamoy/copier-pdm
44
author_email: pawamoy@pm.me
55
author_fullname: "Timoth\xE9e Mazzucotelli"
66
author_username: pawamoy
@@ -16,3 +16,4 @@ python_package_import_name: pytkdocs
1616
repository_name: pytkdocs
1717
repository_namespace: pawamoy
1818
repository_provider: github.com
19+
use_precommit: false

.github/workflows/ci.yml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ defaults:
1313
shell: bash
1414

1515
env:
16-
LANG: "en_US.utf-8"
17-
LC_ALL: "en_US.utf-8"
18-
POETRY_VIRTUALENVS_IN_PROJECT: "true"
19-
PYTHONIOENCODING: "UTF-8"
16+
LANG: en_US.utf-8
17+
LC_ALL: en_US.utf-8
18+
PYTHONIOENCODING: UTF-8
19+
20+
# To fix an error when running Poetry on Windows
21+
# (https://github.com/python-poetry/poetry/issues/2629),
22+
# we set Poetry's cache directory to .poetry_cache in the current directory.
23+
# It makes it easier to later remove the virtualenv when it's broken.
24+
# Absolute path is necessary to avoid this issue:
25+
# https://github.com/python-poetry/poetry/issues/3049
26+
POETRY_CACHE_DIR: ${{ github.workspace }}/.poetry_cache
2027

2128
jobs:
2229

@@ -33,17 +40,17 @@ jobs:
3340
with:
3441
python-version: 3.8
3542

43+
- name: Set up Poetry
44+
run: pip install poetry
45+
3646
- name: Set up the cache
3747
uses: actions/cache@v1
3848
with:
39-
path: .venv
40-
key: quality-venv-cache
49+
path: .poetry_cache
50+
key: quality-poetry-cache
4151

4252
- name: Set up the project
43-
run: |
44-
pip install poetry
45-
poetry install -v -E numpy-style || { rm -rf .venv; poetry install -v -E numpy-style; }
46-
poetry update
53+
run: poetry install -vv -E numpy-style
4754

4855
- name: Check if the documentation builds correctly
4956
run: poetry run duty check-docs
@@ -77,17 +84,17 @@ jobs:
7784
with:
7885
python-version: ${{ matrix.python-version }}
7986

87+
- name: Set up Poetry
88+
run: pip install poetry
89+
8090
- name: Set up the cache
8191
uses: actions/cache@v1
8292
with:
83-
path: .venv
84-
key: tests-venv-cache-${{ matrix.os }}-py${{ matrix.python-version }}
93+
path: .poetry_cache
94+
key: tests-poetry-cache-${{ matrix.os }}-py${{ matrix.python-version }}
8595

8696
- name: Set up the project
87-
run: |
88-
pip install poetry
89-
poetry install -v -E numpy-style || { rm -rf .venv; poetry install -v -E numpy-style; }
90-
poetry update
97+
run: poetry install -vv -E numpy-style || { rm -rf .poetry_cache/virtualenvs/*; poetry install -vv -E numpy-style; }
9198

9299
- name: Run the test suite
93100
run: poetry run duty test

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ args = $(foreach a,$($(subst -,_,$1)_args),$(if $(value $a),$a="$($a)"))
77
check_code_quality_args = files
88
docs_serve_args = host port
99
release_args = version
10-
test_args = cleancov match
10+
test_args = match
1111

1212
BASIC_DUTIES = \
1313
changelog \

config/flake8.ini

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[flake8]
2+
exclude = fixtures,docs,site
3+
max-line-length = 132
4+
docstring-convention = google
5+
ban-relative-imports = true
6+
ignore =
7+
# redundant with W0622 (builtin override), which is more precise about line number
8+
A001
9+
# missing docstring in magic method
10+
D105
11+
# multi-line docstring summary should start at the first line
12+
D212
13+
# whitespace before ':' (incompatible with Black)
14+
E203
15+
# redundant with E0602 (undefined variable)
16+
F821
17+
# black already deals with quoting
18+
Q000
19+
# use of assert
20+
S101
21+
# we are not parsing XML
22+
S405
23+
# line break before binary operator (incompatible with Black)
24+
W503
25+
# two-lowercase-letters variable DO conform to snake_case naming style
26+
C0103
27+
# redunant with D102 (missing docstring)
28+
C0116
29+
# line too long
30+
C0301
31+
# too many instance attributes
32+
R0902
33+
# too few public methods
34+
R0903
35+
# too many public methods
36+
R0904
37+
# too many branches
38+
R0912
39+
# too many methods
40+
R0913
41+
# too many local variables
42+
R0914
43+
# too many statements
44+
R0915
45+
# redundant with F401 (unused import)
46+
W0611
47+
# lazy formatting for logging calls
48+
W1203
49+
# short name
50+
VNE001
51+
# f-strings
52+
WPS305
53+
# common variable names (too annoying)
54+
WPS110
55+
# redundant with W0622 (builtin override), which is more precise about line number
56+
WPS125
57+
# too many imports
58+
WPS201
59+
# too many module members
60+
WPS202
61+
# overused expression
62+
WPS204
63+
# too many local variables
64+
WPS210
65+
# too many arguments
66+
WPS211
67+
# too many expressions
68+
WPS213
69+
# too many methods
70+
WPS214
71+
# too deep nesting
72+
WPS220
73+
# high Jones complexity
74+
WPS221
75+
# too many elif branches
76+
WPS223
77+
# string over-use: can't disable it per file?
78+
WPS226
79+
# too many public instance attributes
80+
WPS230
81+
# too complex f-string
82+
WPS237
83+
# too cumbersome, asks to write class A(object)
84+
WPS306
85+
# multi-line paramaters (incompatible with Black)
86+
WPS317
87+
# multi-line strings (incompatible with attributes docstrings)
88+
WPS322
89+
# implicit string concatenation
90+
WPS326
91+
# explicit string concatenation
92+
WPS336
93+
# noqa overuse
94+
WPS402
95+
# __init__ modules with logic
96+
WPS412
97+
# print statements
98+
WPS421
99+
# statement with no effect (not compatible with attribute docstrings)
100+
WPS428
101+
# redundant with C0415 (not top-level import)
102+
WPS433
103+
# implicit dict.get usage (generally false-positive)
104+
WPS529

config/mypy.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[mypy]
22
ignore_missing_imports = true
3+
exclude = tests/fixtures/
34

45
[mypy-tests.fixtures.*]
5-
ignore_errors = true
6+
ignore_errors = true

config/pytest.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ python_files =
1111
tests.py
1212
addopts =
1313
--cov
14-
--cov-append
1514
--cov-config config/coverage.ini
15+
testpaths =
16+
tests

docs/macros.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ def define_env(env):
7777
"""
7878

7979
@env.macro # noqa: WPS430 (nested function)
80-
def credits(): # noqa: W0612,W0622,WPS430 (unused, shadows credits)
80+
def credits(): # noqa: WPS430
8181
return get_credits()

duties.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import re
5+
import sys
56
from pathlib import Path
67
from shutil import which
78
from typing import List, Optional, Pattern
@@ -100,7 +101,7 @@ def update_changelog(
100101
"""
101102
env = SandboxedEnvironment(autoescape=False)
102103
template = env.from_string(httpx.get(template_url).text)
103-
changelog = Changelog(".", style=commit_style) # noqa: W0621 (shadowing changelog)
104+
changelog = Changelog(".", style=commit_style)
104105

105106
if len(changelog.versions_list) == 1:
106107
last_version = changelog.versions_list[0]
@@ -142,13 +143,13 @@ def changelog(ctx):
142143

143144

144145
@duty(pre=["check_code_quality", "check_types", "check_docs", "check_dependencies"])
145-
def check(ctx): # noqa: W0613 (no use for the context argument)
146+
def check(ctx):
146147
"""
147148
Check it all!
148149
149150
Arguments:
150151
ctx: The context instance (passed automatically).
151-
""" # noqa: D400 (exclamation mark is funnier)
152+
"""
152153

153154

154155
@duty
@@ -160,7 +161,7 @@ def check_code_quality(ctx, files=PY_SRC):
160161
ctx: The context instance (passed automatically).
161162
files: The files to check.
162163
"""
163-
ctx.run(f"flakehell lint {files}", title="Checking code quality", pty=PTY, nofail=True, quiet=True)
164+
ctx.run(f"flake8 --config=config/flake8.ini {files}", title="Checking code quality", pty=PTY)
164165

165166

166167
@duty
@@ -196,7 +197,9 @@ def check_docs(ctx, strict: bool = False):
196197
Arguments:
197198
ctx: The context instance (passed automatically).
198199
"""
199-
ctx.run(f"mkdocs build{' -s' if strict else ''}", title="Building documentation", pty=PTY)
200+
Path("build/coverage").mkdir(parents=True, exist_ok=True)
201+
Path("build/coverage/index.html").touch(exist_ok=True)
202+
ctx.run("mkdocs build -s", title="Building documentation", pty=PTY)
200203

201204

202205
@duty
@@ -221,6 +224,7 @@ def clean(ctx):
221224
ctx.run("rm -rf .coverage*")
222225
ctx.run("rm -rf .mypy_cache")
223226
ctx.run("rm -rf .pytest_cache")
227+
ctx.run("rm -rf tests/.pytest_cache")
224228
ctx.run("rm -rf build")
225229
ctx.run("rm -rf dist")
226230
ctx.run("rm -rf pip-wheel-metadata")
@@ -265,7 +269,7 @@ def docs_deploy(ctx):
265269

266270

267271
@duty
268-
def format(ctx): # noqa: W0622 (we don't mind shadowing the format builtin)
272+
def format(ctx):
269273
"""
270274
Run formatting tools on the code.
271275
@@ -277,7 +281,7 @@ def format(ctx): # noqa: W0622 (we don't mind shadowing the format builtin)
277281
title="Removing unused imports",
278282
pty=PTY,
279283
)
280-
ctx.run(f"isort -y -rc {PY_SRC}", title="Ordering imports", pty=PTY)
284+
ctx.run(f"isort {PY_SRC}", title="Ordering imports", pty=PTY)
281285
ctx.run(f"black {PY_SRC}", title="Formatting code", pty=PTY)
282286

283287

@@ -299,7 +303,7 @@ def release(ctx, version):
299303
ctx.run("git push --tags", title="Pushing tags", pty=False)
300304
ctx.run("poetry build", title="Building dist/wheel", pty=PTY)
301305
ctx.run("poetry publish", title="Publishing version", pty=PTY)
302-
ctx.run("mkdocs gh-deploy", title="Deploying documentation", pty=PTY)
306+
docs_deploy.run() # type: ignore
303307

304308

305309
@duty(silent=True)
@@ -310,22 +314,22 @@ def coverage(ctx):
310314
Arguments:
311315
ctx: The context instance (passed automatically).
312316
"""
317+
ctx.run("coverage combine .coverage-*", nofail=True)
313318
ctx.run("coverage report --rcfile=config/coverage.ini", capture=False)
314319
ctx.run("coverage html --rcfile=config/coverage.ini")
315320

316321

317322
@duty
318-
def test(ctx, cleancov: bool = True, match: str = ""):
323+
def test(ctx, match: str = ""):
319324
"""
320325
Run the test suite.
321326
322327
Arguments:
323328
ctx: The context instance (passed automatically).
324-
cleancov: Whether to remove the `.coverage` file before running the tests.
325329
match: A pytest expression to filter selected tests.
326330
"""
327-
if cleancov:
328-
ctx.run("rm -f .coverage", silent=True)
331+
py_version = f"{sys.version_info.major}{sys.version_info.minor}"
332+
os.environ["COVERAGE_FILE"] = f".coverage-{py_version}"
329333
ctx.run(
330334
["pytest", "-c", "config/pytest.ini", "-n", "auto", "-k", match, "tests"],
331335
title="Running tests",

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ site_description: "Load Python objects documentation."
33
site_url: "https://pawamoy.github.io/pytkdocs"
44
repo_url: "https://github.com/pawamoy/pytkdocs"
55
repo_name: "pawamoy/pytkdocs"
6+
site_dir: "site"
67

78
nav:
89
- Home:
@@ -71,4 +72,4 @@ plugins:
7172
watch:
7273
- src/pytkdocs
7374
- macros:
74-
module_name: docs/macros
75+
module_name: docs/macros

0 commit comments

Comments
 (0)