Skip to content

Commit 9f74d15

Browse files
committed
Use nox instead of tox
This change modifies the strategy used by the project to use `nox` instead of `tox` as the former better supports virtual environment reuse. Signed-off-by: Enji Cooper <[email protected]>
1 parent ea63564 commit 9f74d15

File tree

3 files changed

+60
-62
lines changed

3 files changed

+60
-62
lines changed

.github/workflows/main.yaml

+11-19
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ on:
88

99
jobs:
1010
build:
11-
11+
env:
12+
DEFAULT_PYTHON: 3.12
1213
runs-on: ubuntu-latest
1314
strategy:
1415
matrix:
15-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1617
architecture: ["x64"]
1718
steps:
1819
- uses: actions/checkout@v2
@@ -21,16 +22,7 @@ jobs:
2122
with:
2223
python-version: ${{ matrix.python-version }}
2324
architecture: ${{ matrix.architecture }}
24-
- name: Cache pip 3.8
25-
if: matrix.python-version == 3.8
26-
uses: actions/cache@v4
27-
with:
28-
# This path is specific to Ubuntu
29-
path: ~/.cache/pip
30-
restore-keys: |
31-
${{ runner.os }}-
3225
- name: Cache pip
33-
if: matrix.python-version != 3.8
3426
env:
3527
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
3628
uses: actions/cache@v4
@@ -43,23 +35,23 @@ jobs:
4335
# workaround for 3.12, SEE: https://github.com/pypa/setuptools/issues/3661#issuecomment-1813845177
4436
pip install --upgrade setuptools
4537
- name: Lint with flake8
46-
if: matrix.python-version == 3.12
38+
if: matrix.python-version == ${{ env.DEFAULT_PYTHON }}
4739
run: |
4840
# stop the build if there are Python syntax errors or undefined names
49-
tox -e flake8 -- deepdiff --count --select=E9,F63,F7,F82 --show-source --statistics
41+
nox -e flake8 -- deepdiff --count --select=E9,F63,F7,F82 --show-source --statistics
5042
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
51-
tox -e flake8 -- deepdiff --count --exit-zero --max-complexity=26 --max-line-lengt=250 --statistics
43+
nox -e flake8 -- deepdiff --count --exit-zero --max-complexity=26 --max-line-length=250 --statistics
5244
- name: Test with pytest and get the coverage
53-
if: matrix.python-version == 3.12
45+
if: matrix.python-version == ${{ env.DEFAULT_PYTHON }}
5446
run: |
55-
tox -s -- --benchmark-disable --cov-report=xml --cov=deepdiff tests/ --runslow
47+
nox -e pytest -s -- --benchmark-disable --cov-report=xml --cov=deepdiff tests/ --runslow
5648
- name: Test with pytest and no coverage report
57-
if: matrix.python-version != 3.12
49+
if: matrix.python-version != ${{ env.DEFAULT_PYTHON }}
5850
run: |
59-
tox -s -- --benchmark-disable tests/
51+
nox -e pytest -s -- --benchmark-disable tests/
6052
- name: Upload coverage to Codecov
6153
uses: codecov/codecov-action@v4
62-
if: matrix.python-version == 3.12
54+
if: matrix.python-version == ${{ env.DEFAULT_PYTHON }}
6355
env:
6456
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6557
with:

noxfile.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""nox configuration file."""
2+
3+
# ruff: noqa: ANN001, D401
4+
5+
import nox
6+
7+
8+
@nox.session
9+
def flake8(session) -> None:
10+
"""Run flake8."""
11+
posargs = session.posargs if session.posargs else ["deepdiff"]
12+
session.install(".[cli,dev,static]")
13+
session.run(
14+
"python",
15+
"-m",
16+
"flake8",
17+
*posargs,
18+
)
19+
20+
21+
@nox.session
22+
def mypy(session) -> None:
23+
"""Run mypy."""
24+
posargs = session.posargs if session.posargs else ["deepdiff"]
25+
session.install(".[cli,dev,static]")
26+
session.run(
27+
"python",
28+
"-m",
29+
"mypy",
30+
"--install-types",
31+
"--non-interactive",
32+
*posargs,
33+
)
34+
35+
36+
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
37+
def pytest(session) -> None:
38+
"""Test with pytest."""
39+
posargs = session.posargs if session.posargs else ["-vv", "tests"]
40+
session.install(".[cli,dev,static,test]")
41+
session.run(
42+
"python",
43+
"-m",
44+
"pytest",
45+
"--cov=deepdiff",
46+
"--cov-report",
47+
"term-missing",
48+
*posargs,
49+
)

pyproject.toml

-43
Original file line numberDiff line numberDiff line change
@@ -102,46 +102,3 @@ packages = ["deepdiff"]
102102

103103
[tool.setuptools.package-metadata]
104104
deepdiff = ["py.typed"]
105-
106-
[tool.tox]
107-
legacy_tox_ini = """
108-
[tox]
109-
min_version = 4.0
110-
env_list =
111-
flake8
112-
# XXX: this needs work.
113-
#mypy
114-
py39
115-
py310
116-
py311
117-
py312
118-
py313
119-
120-
[testenv]
121-
deps =
122-
.[cli]
123-
.[coverage]
124-
.[dev]
125-
.[static]
126-
.[test]
127-
commands =
128-
python -m pytest --cov=deepdiff --cov-report term-missing {posargs:-vv tests}
129-
130-
[testenv:flake8]
131-
deps =
132-
.[cli]
133-
.[dev]
134-
.[static]
135-
commands =
136-
python -m flake8 {posargs:deepdiff}
137-
138-
[testenv:mypy]
139-
deps =
140-
.[cli]
141-
.[dev]
142-
.[static]
143-
.[test]
144-
mypy
145-
commands =
146-
python -m mypy --install-types --non-interactive {posargs:deepdiff}
147-
"""

0 commit comments

Comments
 (0)