Skip to content

Commit 1bae937

Browse files
committed
dev: Run flake8 directly as a standalone test instead of using the pytest plugin
The pytest-flake8 plugin is not maintained and has been the source of a lot of spurious CI failures as pytest's API changes and the plugin isn't updated along with it. Rather than continue to play whack-a-mole with the plugin, just run flake8 ourselves as a single standalone test. The plugin broke out flake8 results per Python file in pytest's output, but that's not really necessary. This follows a similar move we made with mypy some time ago.
1 parent a41b2be commit 1bae937

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

pytest.ini

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[pytest]
2-
addopts = --flake8 --doctest-modules
2+
addopts = --doctest-modules
33
testpaths = nextstrain tests
44
python_files = *.py
55

@@ -12,7 +12,3 @@ python_functions = pytest_*
1212
# for them. Last matching filter wins.
1313
filterwarnings =
1414
error
15-
ignore:SelectableGroups dict interface:DeprecationWarning:flake8
16-
ignore:<class 'pytest_flake8[.]Flake8Item'> is not using a cooperative constructor:pytest.PytestDeprecationWarning
17-
ignore:The .+? argument to Flake8Item is deprecated:pytest.PytestDeprecationWarning
18-
ignore:Flake8Item is an Item subclass and should not be a collector:pytest.PytestWarning

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def find_namespaced_packages(namespace):
124124
"nextstrain-sphinx-theme",
125125
"pytest; python_version != '3.9'",
126126
"pytest !=7.0.0; python_version == '3.9'",
127-
"pytest-flake8",
128127
"recommonmark",
129128
"sphinx>=3",
130129
"sphinx-argparse ~=0.3",

tests/flake8.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from pathlib import Path
2+
from subprocess import run
3+
4+
topdir = Path(__file__).resolve().parent.parent
5+
6+
def pytest_flake8():
7+
# Check the exit status ourselves for nicer test output on failure
8+
result = run(["flake8"], cwd = topdir)
9+
assert result.returncode == 0, "flake8 exited with errors"

0 commit comments

Comments
 (0)