This repository was archived by the owner on Apr 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtox.ini
81 lines (74 loc) · 2.95 KB
/
tox.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
[tox]
# These environments will be run when "tox" is invoked. A specific environment
# can be run with e.g., tox -e lint
envlist =
lint,
lint-format,
types,
# It is good practice to test the library for all supported versions.
py38,
py39,
py310,
py311,
py312
min_version = 4.0
[testenv]
# Run pytest and measure coverage.
deps = -r{toxinidir}/requirements/requirements-{envname}-dev.txt
commands =
pytest --cov=python_example --cov-report=xml
[testenv:lint]
# Run the linter for both src and tests folders.
basepython = python3.8
deps = -r{toxinidir}/requirements/requirements-py38-dev.txt
commands =
pylint {toxinidir}/src/python_example {toxinidir}/tests
[testenv:lint-format]
# Check the code format by running black and isort in check mode.
basepython = python3.8
deps = -r{toxinidir}/requirements/requirements-py38-dev.txt
commands =
black --diff --check {toxinidir}
isort --diff --check-only {toxinidir}
[testenv:types]
# Run mypy linter. Mypy needs to be run in src and tests separately to not
# cause errors with imports.
basepython = python3.8
deps = -r{toxinidir}/requirements/requirements-py38-dev.txt
commands =
mypy {toxinidir}/src
mypy {toxinidir}/tests
[testenv:format]
# Applies the formatting from black and isort. Not run by default when invoking
# tox but provides an easy way to fix format errors. Run with tox -e format
basepython = python3.8
deps = -r{toxinidir}/requirements/requirements-py38-dev.txt
commands =
black {toxinidir}
isort {toxinidir}
[testenv:requirements-py{38,39,310,311,312}]
; Generate new requirements files
; only run this on linux as compiled requirements are platform dependent and
; this code is deployed in linux containers.
; Would be better to only run this on a specific processor architecture, but
; this is not supported in tox at the moment.
labels = requirements
platform = linux
deps = pip-tools
skip_install = true
setenv =
; will show `tox run -m requirements` in the top of the generated files.
CUSTOM_COMPILE_COMMAND='tox run -m requirements'
commands =
; ensure that the requirements-folder exists
python3 -c 'import pathlib;pathlib.Path("requirements").mkdir(exist_ok=True)'
; explanation of flags used
; --upgrade: upgrade all dependencies to latest version. normally pip-compile
; change as little as possible, but without constraints it means that
; it will never update transitive dependencies.
; --resolver backtracking: use the "new" improved backtracking resolver from
; pip. this will be default in pip-tools 7.
; --allow-unsafe: allow the "unsafe" packages, which will be default behaviour
; in upcoming pip-tools version.
pip-compile --upgrade --strip-extras --generate-hashes --resolver backtracking --allow-unsafe pyproject.toml --output-file requirements/{envname}.txt
pip-compile --extra format,lint,types,test --constraint requirements/{envname}.txt --strip-extras --upgrade --generate-hashes --resolver backtracking --allow-unsafe pyproject.toml --output-file requirements/{envname}-dev.txt