Skip to content

Commit 44b7e76

Browse files
committed
simplify testing pipeline
1 parent 9350408 commit 44b7e76

File tree

7 files changed

+50
-49
lines changed

7 files changed

+50
-49
lines changed

.github/workflows/tests.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,47 @@ jobs:
77
matrix:
88
os: ['ubuntu-20.04']
99
python-version:
10-
- 3.7
11-
- 3.8
12-
- 3.9
13-
- pypy-3.7
14-
- pypy-3.8
15-
- pypy-3.9
16-
- pypy-3.10
10+
- '3.7'
11+
- '3.8'
12+
- '3.9'
13+
- 'pypy-3.7'
14+
- 'pypy-3.8'
15+
- 'pypy-3.9'
16+
- 'pypy-3.10'
1717
tox-env: ['essential']
1818
include:
1919
- os: macos-latest
2020
python-version: '3.12'
2121
tox-env: essential
2222
- os: windows-latest
23-
python-version: '3.12'
23+
python-version: '3.11'
2424
tox-env: essential
2525
- os: ubuntu-latest
2626
python-version: '3.10'
27-
tox-env: linters
28-
- os: ubuntu-latest
29-
python-version: '3.11'
30-
tox-env: coverage
27+
tox-env: extended
3128
steps:
3229
- uses: actions/checkout@v4
3330

3431
- name: Set up Python ${{ matrix.python-version }}
3532
uses: actions/setup-python@v5
3633
with:
3734
python-version: ${{ matrix.python-version }}
35+
cache: 'pip'
3836

3937
- name: Install dependencies
4038
run: |
4139
pip install --quiet --upgrade pip setuptools tox>=4.5.1
4240
43-
- name: Run test without coverage
44-
if: ${{ matrix.tox-env != 'coverage' }}
41+
- name: Run essential tests
42+
if: ${{ matrix.tox-env != 'extended' }}
4543
run: |
4644
tox run -e ${{ matrix.tox-env }}
4745
48-
- name: Run tests with coverage
49-
if: ${{ matrix.tox-env == 'coverage' }}
46+
- name: Run linters and coverage
47+
if: ${{ matrix.tox-env == 'extended' }}
5048
env:
5149
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5250
run: |
5351
pip install --quiet --upgrade coveralls
54-
tox run -e coverage
52+
tox run -e ${{ matrix.tox-env }}
5553
coveralls --service=github

nested_diff/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141

4242

4343
class Differ:
44-
"""
45-
Compute recursive diff for two passed objects.
44+
"""Compute recursive diff for two passed objects.
4645
4746
Dicts, lists, tuples, sets and frozensets traversed recursively, other
4847
types compared by values. Any type diff may be customized by user-defined

nested_diff/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def run(self):
228228
Raises:
229229
NotImplementedError: Must be implemented in derivatives.
230230
231-
"""
231+
""" # noqa: D406
232232
raise NotImplementedError
233233

234234

nested_diff/diff_tool.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ def get_dumper(self, fmt, **kwargs):
208208
209209
"""
210210
if fmt == 'auto':
211-
if self.args.out.isatty():
212-
fmt = 'term'
213-
else:
214-
fmt = 'text'
211+
fmt = 'term' if self.args.out.isatty() else 'text'
215212

216213
if fmt in FormatterDumper.supported_fmts:
217214
return FormatterDumper(fmt=fmt, values=self.args.values, **kwargs)

nested_diff/handlers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def diff(self, differ, a, b):
212212
>>> Differ(handlers=[DictHandler()], O=False, U=False).diff(a, b)
213213
(False, {'D': {'three': {'R': 3}, 'two': {'N': 42}}})
214214
>>>
215+
215216
"""
216217
diff = {}
217218
equal = True
@@ -243,10 +244,7 @@ def diff(self, differ, a, b):
243244
diff[key] = subdiff
244245

245246
if diff:
246-
if equal:
247-
diff = {'U': a}
248-
else:
249-
diff = {'D': diff}
247+
diff = {'U': a} if equal else {'D': diff}
250248
elif equal and differ.op_u:
251249
diff = {'U': a}
252250

@@ -341,6 +339,7 @@ def diff(self, differ, a, b):
341339
>>> Differ(handlers=[ListHandler()], O=False, U=False).diff(a, b)
342340
(False, {'D': [{'R': 0}, {'N': 4, 'I': 3}, {'A': 5}]})
343341
>>>
342+
344343
"""
345344
self.lcs.set_seq1(tuple(differ.dump(i) for i in a))
346345
self.lcs.set_seq2(tuple(differ.dump(i) for i in b))
@@ -509,6 +508,7 @@ def diff(self, differ, a, b):
509508
>>> Differ(handlers=[TupleHandler()], O=False, U=False).diff(a, b)
510509
(False, {'D': ({'A': 0}, {'N': 3, 'I': 2}, {'R': 5})})
511510
>>>
511+
512512
"""
513513
equal, diff = super().diff(differ, a, b)
514514

@@ -559,6 +559,7 @@ def diff(self, differ, a, b):
559559
>>> Differ(handlers=[SetHandler()], U=False).diff(a, b)
560560
(False, {'D': [{'R': 1}, {'A': 3}], 'E': 3})
561561
>>>
562+
562563
"""
563564
diff = []
564565
equal = True
@@ -677,6 +678,7 @@ def diff(self, differ, a, b):
677678
(False,
678679
{'D': [{'I': [0, 1, 0, 2]}, {'U': 'one'}, {'A': 'two'}], 'E': 5})
679680
>>>
681+
680682
"""
681683
lines_a = a.split('\n', -1)
682684
lines_b = b.split('\n', -1)

pyproject.toml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ lint = [
6060
'flake8-pytest-style',
6161
'flake8_quotes',
6262
'flake8-return',
63-
'flake8-simplify',
6463
'flake8-unused-arguments',
6564
'pep8-naming',
6665
'pytest-flake8',
6766
]
6867
test = [
6968
'pytest',
69+
'pytest-cov',
7070
'pytest-ruff',
71-
'ruff==0.1.15', # pin for reproducible results
71+
'ruff==0.3.0', # pin for reproducible results
7272
]
7373

7474
[project.scripts]
@@ -81,6 +81,10 @@ Repository = 'https://github.com/mr-mixas/Nested-Diff.py.git'
8181

8282
[tool.pytest.ini_options]
8383
addopts = """
84+
--cov=nested_diff \
85+
--cov-fail-under=99 \
86+
--cov-report term-missing \
87+
--no-cov-on-fail \
8488
--ruff \
8589
--ruff-format \
8690
--verbosity=2 \
@@ -94,8 +98,23 @@ extend-exclude = [
9498
'tests/data/standard.py',
9599
]
96100
line-length = 79
97-
select = []
101+
102+
[tool.ruff.extend-per-file-ignores]
103+
'tests/*' = [
104+
'D', # docstrings
105+
]
98106

99107
[tool.ruff.format]
100108
docstring-code-format = true
101109
quote-style = 'single'
110+
111+
[tool.ruff.lint]
112+
select = [
113+
'D',
114+
'E501',
115+
'SIM',
116+
]
117+
ignore = [
118+
'D407', # Missing dashed underline after section
119+
'SIM105', # contextlib.suppress is slower than try-except-pass
120+
]

tox.ini

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = linters
2+
envlist = extended
33
usedevelop = true
44

55
[testenv:essential]
@@ -13,20 +13,7 @@ extras =
1313
setenv =
1414
PYTHONHASHSEED = 1
1515

16-
[testenv:coverage]
17-
commands =
18-
coverage run --source nested_diff -m pytest
19-
20-
deps =
21-
coverage
22-
23-
extras =
24-
{[testenv:essential]extras}
25-
26-
setenv =
27-
PYTHONHASHSEED = 1
28-
29-
[testenv:linters]
16+
[testenv:extended]
3017
commands =
3118
pytest --doctest-modules --flake8
3219
python -m doctest HOWTO.md README.md
@@ -44,10 +31,9 @@ docstring_style=google
4431
strictness=short
4532

4633
# pyproject.toml not support yet
34+
# TODO: remove when migration complete (already handled by ruff)
4735
[flake8]
4836
max-line-length = 79
4937
per-file-ignores =
50-
# disable SIM105 (contextlib.suppress is slower than using try-except-pass)
51-
nested_diff/*: SIM105
5238
# disable max line length and all docstrings checks in tests dir
53-
tests/*: E501 D SIM105
39+
tests/*: E501 D

0 commit comments

Comments
 (0)