Skip to content

Bump reuse-tool pre-commit hook to v6.2.0#33

Merged
makermelissa merged 1 commit into
adafruit:mainfrom
makermelissa-piclaw:bump-reuse-tool
May 20, 2026
Merged

Bump reuse-tool pre-commit hook to v6.2.0#33
makermelissa merged 1 commit into
adafruit:mainfrom
makermelissa-piclaw:bump-reuse-tool

Conversation

@makermelissa-piclaw

Copy link
Copy Markdown
Contributor

Bumps the fsfe/reuse-tool pre-commit hook from v1.1.2 → v6.2.0 to unblock CI.

Why

reuse-tool v1.x imports pkg_resources at startup, which lives inside setuptools. Python ≥ 3.12 no longer bundles setuptools by default, so on the current GitHub Actions Python runners the hook now crashes at import time with:

File ".../reuse/__init__.py", line 15, in <module>
    from pkg_resources import DistributionNotFound, get_distribution
ModuleNotFoundError: No module named 'pkg_resources'

PR #31 (merged 2025-11) was the last successful run; the runner environment has drifted since.

Why this specific version

v6.2.0 is what adafruit/Adafruit_CircuitPython_Display_Text is currently using on its main branch, so it matches a known-good Adafruit reference.

Scope

Single-line change to .pre-commit-config.yaml. Intentionally narrow — a follow-up to migrate the whole config to ruff (replacing black + pylint, matching the CircuitPython-library convention) is planned separately.

Verification

Ran pre-commit run --all-files inside python:3.11-slim (the same Python the CI workflow uses):

black....................................................................Passed
reuse lint...............................................................Passed
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
pylint (library code)....................................................Passed
pylint (example code)................................(no files to check)Skipped
pylint (test code)...................................(no files to check)Skipped

The pinned v1.1.2 fails on current GitHub Actions Python runners
because reuse-tool v1.x imports pkg_resources at startup, and
Python >= 3.12 no longer bundles setuptools (which provides
pkg_resources) by default. v6.2.0 has dropped that import.

Verified locally under python:3.11-slim with pre-commit run
--all-files: black, reuse lint, check yaml, fix end of files,
trim trailing whitespace, and pylint (library code) all pass.
@makermelissa makermelissa merged commit eca5d14 into adafruit:main May 20, 2026
1 check passed
makermelissa pushed a commit that referenced this pull request May 20, 2026
Replaces the python/black and pycqa/pylint hooks with the unified
astral-sh/ruff-pre-commit (ruff-format + ruff --fix), matching the
convention used by adafruit/Adafruit_CircuitPython_Display_Text and
the rest of the CircuitPython library ecosystem.

Why
---
- One tool instead of two -> faster CI, fewer pinned versions to drift.
- Ruff tracks new Python stdlib changes promptly; we just hit
  pkg_resources being removed in 3.12+ which broke reuse-tool v1.1.2
  (#33) and would similarly bite the pinned black 23.3.0 / pylint
  v2.17.4 if the runner ever moves past 3.11.

Config
------
.pre-commit-config.yaml:
  - Drop python/black v23.3.0
  - Drop pycqa/pylint v2.17.4 (library / example / test entries)
  - Add astral-sh/ruff-pre-commit v0.15.8 (ruff-format + ruff --fix)
  - Reorder so pre-commit-hooks runs first (matches Display_Text)

ruff.toml:
  - Copied verbatim from Adafruit_CircuitPython_Display_Text/main
    (target-version py38, line-length 100, select I/PL/UP plus the
    per-rule extends)
  - Added PLR0904 / PLR0911 to the ignore list because the Shell
    class is a kitchen-sink utility with 65 public methods and
    multiple-return paths by design; refactoring that out is way
    out of scope for a CI-config migration.

Code changes
------------
Five trivial cleanups ruff flagged (PLC1901, PLR6201, UP009, UP015,
I001):
  - 'x != ""' -> 'x' for the four stream-empty checks in
    run_command and one in prompt() (read_stream returns '' for
    'no data', so this is a no-op semantically).
  - 'in ["y", "n"]' -> 'in {"y", "n"}' in prompt() default
    normalization.
  - Removed the redundant '# -*- coding: utf-8 -*-' magic comment
    from docs/conf.py (Python 3 default).
  - Sorted imports in adafruit_shell.py and docs/conf.py.
  - Dropped the now-redundant 'r' mode in open(template, 'r').

Verified locally inside python:3.11-slim (matches the GitHub Actions
runner Python) -- 'pre-commit run --all-files' passes: check yaml,
fix end of files, trim trailing whitespace, ruff format, ruff
(legacy alias), reuse lint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants