Skip to content

Commit

Permalink
Delivery of compatibility for Flake8 from version 4 to the latest ver…
Browse files Browse the repository at this point in the history
…sion.
  • Loading branch information
pypros committed Oct 27, 2024
1 parent 1cdfa29 commit f536c53
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
9 changes: 9 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v1.3.0
======

Features
--------

- Compatible for Flake8 from version flake8>=4. (#??)


v1.2.2
======

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
]
requires-python = ">=3.8"
dependencies = [
"flake8 >= 5, < 6",
"flake8 >= 4.0",
"pytest >= 7.0",
]
dynamic = ["version"]
Expand Down
27 changes: 3 additions & 24 deletions pytest_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from io import BytesIO, TextIOWrapper

from flake8.main import application
from flake8.options import config

import pytest

Expand Down Expand Up @@ -223,29 +222,9 @@ def check_file(
args += ['--show-source']
if statistics:
args += ['--statistics']
args += [str(path)]
app = application.Application()
prelim_opts, remaining_args = app.parse_preliminary_options(args)
cfg, cfg_dir = config.load_config(
config=prelim_opts.config,
extra=prelim_opts.append_config,
isolated=prelim_opts.isolated,
)
app.find_plugins(
cfg,
cfg_dir,
enable_extensions=prelim_opts.enable_extensions,
require_plugins=prelim_opts.require_plugins,
)
app.register_plugin_options()
app.parse_configuration_and_cli(cfg, cfg_dir, remaining_args)
if flake8ignore:
app.options.ignore = flake8ignore
app.make_formatter() # fix this
app.make_guide()
app.make_file_checker_manager()
app.run_checks()
app.formatter.start()
app.report_errors()
app.formatter.stop()
args += ["--ignore", flake8ignore]
args += [str(path)]
app.run(args)
return app.result_count
7 changes: 7 additions & 0 deletions tests/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import pathlib
import textwrap
from packaging import version

import pytest

from flake8 import __version__ as flake8_version

pytest_plugins = ("pytester",)


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

@pytest.mark.xfail(
version.parse(flake8_version) >= version.parse("6.0.0"),
reason="Requires Flake8 version earlier than 6.0.0.",
)
def test_default_flake8_ignores(self, testdir):
testdir.makeini("""
[pytest]
Expand Down

0 comments on commit f536c53

Please sign in to comment.