From f536c53a6db51bdecdf800e90058d54bcf244e94 Mon Sep 17 00:00:00 2001 From: Lukasz Sobczuk Date: Sun, 27 Oct 2024 08:45:36 +0100 Subject: [PATCH 1/7] Delivery of compatibility for Flake8 from version 4 to the latest version. --- NEWS.rst | 9 +++++++++ pyproject.toml | 2 +- pytest_flake8.py | 27 +++------------------------ tests/test_flake8.py | 7 +++++++ 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 1d4638c..85feb53 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,3 +1,12 @@ +v1.3.0 +====== + +Features +-------- + +- Compatible for Flake8 from version flake8>=4. (#??) + + v1.2.2 ====== diff --git a/pyproject.toml b/pyproject.toml index f73ab99..ec7e05e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ ] requires-python = ">=3.8" dependencies = [ - "flake8 >= 5, < 6", + "flake8 >= 4.0", "pytest >= 7.0", ] dynamic = ["version"] diff --git a/pytest_flake8.py b/pytest_flake8.py index 78475bd..8fafe02 100644 --- a/pytest_flake8.py +++ b/pytest_flake8.py @@ -6,7 +6,6 @@ from io import BytesIO, TextIOWrapper from flake8.main import application -from flake8.options import config import pytest @@ -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 diff --git a/tests/test_flake8.py b/tests/test_flake8.py index 8c8b73f..3ff63e2 100644 --- a/tests/test_flake8.py +++ b/tests/test_flake8.py @@ -2,9 +2,12 @@ import pathlib import textwrap +from packaging import version import pytest +from flake8 import __version__ as flake8_version + pytest_plugins = ("pytester",) @@ -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] From 61ad7cb29bf42feeb145bc643a349f78f56f735f Mon Sep 17 00:00:00 2001 From: Lukasz Sobczuk Date: Sun, 27 Oct 2024 08:53:13 +0100 Subject: [PATCH 2/7] Updated PR number in NEWS.rst --- NEWS.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.rst b/NEWS.rst index 85feb53..a032d68 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -4,7 +4,7 @@ v1.3.0 Features -------- -- Compatible for Flake8 from version flake8>=4. (#??) +- Compatible for Flake8 from version flake8>=4. (#4) v1.2.2 From de5588106f125e2d1171cd7124000ce3029b2428 Mon Sep 17 00:00:00 2001 From: Lukasz Sobczuk Date: Sun, 27 Oct 2024 17:32:37 +0100 Subject: [PATCH 3/7] Updated README.rst --- README.rst | 74 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 1437b08..7612008 100644 --- a/README.rst +++ b/README.rst @@ -1,21 +1,31 @@ -.. image:: https://img.shields.io/pypi/v/pytest-flake8.svg +.. image:: https://img.shields.io/pypi/v/pytest-flake8.svg?label=pytest-flake8 :target: https://pypi.org/project/pytest-flake8 + :alt: Package -.. image:: https://img.shields.io/pypi/pyversions/pytest-flake8.svg -.. image:: https://github.com/coherent-oss/pytest-flake8/actions/workflows/main.yml/badge.svg - :target: https://github.com/coherent-oss/pytest-flake8/actions?query=workflow%3A%22tests%22 - :alt: tests +.. image:: https://readthedocs.org/projects/pytest-flake8/badge + :target: https://pytest-flake8.readthedocs.io/en/latest + :alt: Documentation + + +.. image:: https://github.com/coherent-oss/pytest-flake8/actions/workflows/main.yml/badge.svg?label=test + :target: https://github.com/PyCQA/flake8/actions?query=workflow=main + :alt: Tests + + +.. image:: https://img.shields.io/pypi/v/flake8.svg?label=flake8 + :target: https://github.com/PyCQA/flake8 + :alt: Flake8 + .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json :target: https://github.com/astral-sh/ruff :alt: Ruff -.. image:: https://readthedocs.org/projects/pytest-flake8/badge/?version=latest - :target: https://pytest-flake8.readthedocs.io/en/latest/?badge=latest .. image:: https://img.shields.io/badge/skeleton-2024-informational :target: https://blog.jaraco.com/skeleton + :alt: skeleton pytest plugin for efficiently checking PEP8 compliance @@ -24,7 +34,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 @@ -60,7 +72,51 @@ 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 + +Note to developers +------------------ + +Setup environment +^^^^^^^^^^^^^^^^^ + +Separate virtual environments(venv) should be set up. + +.. code-block:: bash + + python3 -m venv .venv + +Switch to venv. + +.. code-block:: bash + + source .venv/bin/activate + +Install tox +^^^^^^^^^^^ + +Separate virtual environments should be set up. + +.. code-block:: bash + + pip install tox + + +Run environment +^^^^^^^^^^^^^^^ + +Run tox. + +.. code-block:: bash + + tox + +For more information, you can take a look at the `skeleton `_. + Notes ----- From a4abd57833dc9b0a2e4ff6714a30a647be6a8837 Mon Sep 17 00:00:00 2001 From: Lukasz Sobczuk Date: Tue, 29 Oct 2024 20:03:50 +0100 Subject: [PATCH 4/7] Update README.rst Co-authored-by: Jason R. Coombs --- README.rst | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/README.rst b/README.rst index 7612008..131778f 100644 --- a/README.rst +++ b/README.rst @@ -78,42 +78,7 @@ To bypass this caching mechanism, run the following command: pytest --cache-clear --flake8 -Note to developers ------------------- - -Setup environment -^^^^^^^^^^^^^^^^^ - -Separate virtual environments(venv) should be set up. - -.. code-block:: bash - - python3 -m venv .venv - -Switch to venv. - -.. code-block:: bash - - source .venv/bin/activate - -Install tox -^^^^^^^^^^^ - -Separate virtual environments should be set up. - -.. code-block:: bash - - pip install tox - - -Run environment -^^^^^^^^^^^^^^^ - -Run tox. - -.. code-block:: bash - - tox +Run tests with [tox](https://tox.wiki) (e.g. `pipx run tox`). For more information, you can take a look at the `skeleton `_. From a97ff18d6c340618a9f46a497893d476da70e5b8 Mon Sep 17 00:00:00 2001 From: Lukasz Sobczuk Date: Tue, 29 Oct 2024 20:04:03 +0100 Subject: [PATCH 5/7] Update README.rst Co-authored-by: Jason R. Coombs --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 131778f..636bf50 100644 --- a/README.rst +++ b/README.rst @@ -80,7 +80,7 @@ To bypass this caching mechanism, run the following command: Run tests with [tox](https://tox.wiki) (e.g. `pipx run tox`). -For more information, you can take a look at the `skeleton `_. +For more information, take a look at the `skeleton `_. Notes From fb5516e172148afd1220f5851980e486422c91c1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 8 Nov 2024 19:01:33 -0500 Subject: [PATCH 6/7] Restore badge configuration. --- README.rst | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/README.rst b/README.rst index 636bf50..0fd1dab 100644 --- a/README.rst +++ b/README.rst @@ -1,31 +1,21 @@ -.. image:: https://img.shields.io/pypi/v/pytest-flake8.svg?label=pytest-flake8 +.. image:: https://img.shields.io/pypi/v/pytest-flake8.svg :target: https://pypi.org/project/pytest-flake8 - :alt: Package +.. image:: https://img.shields.io/pypi/pyversions/pytest-flake8.svg -.. image:: https://readthedocs.org/projects/pytest-flake8/badge - :target: https://pytest-flake8.readthedocs.io/en/latest - :alt: Documentation - - -.. image:: https://github.com/coherent-oss/pytest-flake8/actions/workflows/main.yml/badge.svg?label=test - :target: https://github.com/PyCQA/flake8/actions?query=workflow=main - :alt: Tests - - -.. image:: https://img.shields.io/pypi/v/flake8.svg?label=flake8 - :target: https://github.com/PyCQA/flake8 - :alt: Flake8 - +.. image:: https://github.com/coherent-oss/pytest-flake8/actions/workflows/main.yml/badge.svg + :target: https://github.com/coherent-oss/pytest-flake8/actions?query=workflow%3A%22tests%22 + :alt: tests .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json :target: https://github.com/astral-sh/ruff :alt: Ruff +.. image:: https://readthedocs.org/projects/pytest-flake8/badge/?version=latest + :target: https://pytest-flake8.readthedocs.io/en/latest/?badge=latest .. image:: https://img.shields.io/badge/skeleton-2024-informational :target: https://blog.jaraco.com/skeleton - :alt: skeleton pytest plugin for efficiently checking PEP8 compliance From 7c68e656a1febb2f5f3eb38bfa07a9ea5873f032 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 8 Nov 2024 19:03:51 -0500 Subject: [PATCH 7/7] Move news change to news fragment. --- NEWS.rst | 9 --------- newsfragments/4.feature.rst | 1 + 2 files changed, 1 insertion(+), 9 deletions(-) create mode 100644 newsfragments/4.feature.rst diff --git a/NEWS.rst b/NEWS.rst index a032d68..1d4638c 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,12 +1,3 @@ -v1.3.0 -====== - -Features --------- - -- Compatible for Flake8 from version flake8>=4. (#4) - - v1.2.2 ====== diff --git a/newsfragments/4.feature.rst b/newsfragments/4.feature.rst new file mode 100644 index 0000000..2e9320a --- /dev/null +++ b/newsfragments/4.feature.rst @@ -0,0 +1 @@ +Compatible for Flake8 from version ``flake8>=4``. \ No newline at end of file