Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delivery of compatibility for Flake8 from version 4 to the latest ver… #4

Merged
merged 8 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. (#4)
jaraco marked this conversation as resolved.
Show resolved Hide resolved


v1.2.2
======

Expand Down
15 changes: 13 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ pytest plugin for efficiently checking PEP8 compliance
Usage
-----

Install it into a test environment, then run tests with the option::
Install it into a test environment, then run tests with the option.

.. code-block:: bash

pytest --flake8

Expand Down Expand Up @@ -60,7 +62,16 @@ All the Flake8 tests are skipping!

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

Run with ``pytest --cache-clear --flake8`` to bypass.
To bypass this caching mechanism, run the following command:

.. code-block:: bash

pytest --cache-clear --flake8

Run tests with [tox](https://tox.wiki) (e.g. `pipx run tox`).

For more information, take a look at the `skeleton <https://blog.jaraco.com/skeleton/>`_.


Notes
-----
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.9"
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