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 3 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
74 changes: 65 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to avoid changes to the badges here, as they're now managed upstream in jaraco/skeleton. If these changes are important, let's contribute them back to the skeleton. It's okay for a downstream project to have an extra badge, though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original view pytest-flake8 1.2.2:
image

Skeleton view master:
image

From current PR view:
image

I have made some changes because, as you may notice in the documentation for version 1.2.2, there is a blue underline (very tiny) appearing between the labels tests and Ruff. This issue is likely related to the SVG extension at the end. In the skeleton, it may be unnoticeable due to other styles being present so to enhance clarity and coherence for this project, I have added a label and made adjustments to ensure that the pages appear more consistent and user-friendly.

I haven't looked into the skeleton project. I made the changes with varying degrees of familiarity with HTML and by reviewing the badges. I would prefer to focus on delivering a functioning version of pytest-flake8, and I would like others to benefit from this as well. I also apologize in advance for my English, as it is not at the highest level, and I often hear from people that it sounds very harsh, which is not my intention.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very strange situation, and it looks good on PyPI...

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaraco do you know what might be causing these differences? Is there a difference in generating HTML and CSS from .rst files? Are there any other mechanisms involved?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaraco Do you have any suggestion in which direction we should go with this delivery?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recognize the skeleton project isn't something that's familiar to everyone. It's a way of dealing with the common concerns of project management across projects.

The skeleton project itself is never released, so whatever rendering you see of the badges in skeleton is ignorable. What really matters is what is rendered for the downstream projects (after substituting real project names for concrete projects).

I'm aware there are some issues with the rendering of badges in some situations. I'm unwilling to "fix" the rendering of the badges for individual projects. If the issue can be fixed for all projects, I'm good with that, but it needs to happen in the skeleton. My recommendation - just revert all changes to the badges and instead contribute the same changes upstream in the skeleton. The only thing I'm likely to accept in this project is an additional badge that appears after the "skeleton" badge.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, let's just revert these changes and deal with them separately, so they aren't blocking the other changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

: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
Expand All @@ -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

Expand Down Expand Up @@ -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
pypros marked this conversation as resolved.
Show resolved Hide resolved

For more information, you can take a look at the `skeleton <https://blog.jaraco.com/skeleton/>`_.
pypros marked this conversation as resolved.
Show resolved Hide resolved


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.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