22
33import os
44import re
5+ import sys
56from pathlib import Path
67from shutil import which
78from 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" ,
0 commit comments