Skip to content

Commit 2c43c7a

Browse files
authored
Merge pull request #4 from pypros/update-flake8-compat-4.x-to-latest
Delivery of compatibility for Flake8 from version 4 to the latest ver…
2 parents 45103f1 + 7c68e65 commit 2c43c7a

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

README.rst

+13-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ pytest plugin for efficiently checking PEP8 compliance
2424
Usage
2525
-----
2626

27-
Install it into a test environment, then run tests with the option::
27+
Install it into a test environment, then run tests with the option.
28+
29+
.. code-block:: bash
2830
2931
pytest --flake8
3032
@@ -60,7 +62,16 @@ All the Flake8 tests are skipping!
6062

6163
By design, results are cached and only changed files are checked.
6264

63-
Run with ``pytest --cache-clear --flake8`` to bypass.
65+
To bypass this caching mechanism, run the following command:
66+
67+
.. code-block:: bash
68+
69+
pytest --cache-clear --flake8
70+
71+
Run tests with [tox](https://tox.wiki) (e.g. `pipx run tox`).
72+
73+
For more information, take a look at the `skeleton <https://blog.jaraco.com/skeleton/>`_.
74+
6475

6576
Notes
6677
-----

newsfragments/4.feature.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Compatible for Flake8 from version ``flake8>=4``.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ classifiers = [
2424
]
2525
requires-python = ">=3.9"
2626
dependencies = [
27-
"flake8 >= 5, < 6",
27+
"flake8 >= 4.0",
2828
"pytest >= 7.0",
2929
]
3030
dynamic = ["version"]

pytest_flake8.py

+3-24
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from io import BytesIO, TextIOWrapper
77

88
from flake8.main import application
9-
from flake8.options import config
109

1110
import pytest
1211

@@ -226,29 +225,9 @@ def check_file(
226225
args += ['--show-source']
227226
if statistics:
228227
args += ['--statistics']
229-
args += [str(path)]
230228
app = application.Application()
231-
prelim_opts, remaining_args = app.parse_preliminary_options(args)
232-
cfg, cfg_dir = config.load_config(
233-
config=prelim_opts.config,
234-
extra=prelim_opts.append_config,
235-
isolated=prelim_opts.isolated,
236-
)
237-
app.find_plugins(
238-
cfg,
239-
cfg_dir,
240-
enable_extensions=prelim_opts.enable_extensions,
241-
require_plugins=prelim_opts.require_plugins,
242-
)
243-
app.register_plugin_options()
244-
app.parse_configuration_and_cli(cfg, cfg_dir, remaining_args)
245229
if flake8ignore:
246-
app.options.ignore = flake8ignore
247-
app.make_formatter() # fix this
248-
app.make_guide()
249-
app.make_file_checker_manager()
250-
app.run_checks()
251-
app.formatter.start()
252-
app.report_errors()
253-
app.formatter.stop()
230+
args += ["--ignore", flake8ignore]
231+
args += [str(path)]
232+
app.run(args)
254233
return app.result_count

tests/test_flake8.py

+7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import pathlib
44
import textwrap
5+
from packaging import version
56

67
import pytest
78

9+
from flake8 import __version__ as flake8_version
10+
811
pytest_plugins = ("pytester",)
912

1013

@@ -39,6 +42,10 @@ def test_ignores(self, tmpdir):
3942
assert ign(tmpdir.join("a/y.py")) == "E203 E300".split()
4043
assert ign(tmpdir.join("a/z.py")) is None
4144

45+
@pytest.mark.xfail(
46+
version.parse(flake8_version) >= version.parse("6.0.0"),
47+
reason="Requires Flake8 version earlier than 6.0.0.",
48+
)
4249
def test_default_flake8_ignores(self, testdir):
4350
testdir.makeini("""
4451
[pytest]

0 commit comments

Comments
 (0)