Skip to content

Lint the Python code with ruff and check license headers - #22

Merged
ru551n merged 2 commits into
VUnit:mainfrom
ru551n:ci/ruff
Oct 13, 2026
Merged

ru551n merged 2 commits into
VUnit:mainfrom
ru551n:ci/ruff

Conversation

@ru551n

@ru551n ru551n commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Adds linting of the Python code with ruff, and a check of the license headers of all source files.

Ruff

  • pyflakes (F): unused imports and variables, undefined names and similar errors.
  • pycodestyle errors and warnings (E, W): including a line length of 120, the same as black's.

The configuration is in pyproject.toml. The rules are listed explicitly rather than taken from ruff's defaults, which change between releases. Ruff 0.17's defaults would also report 87 style findings (UP, SIM, C4, ...) in code that other open PRs change.

License headers

tools/check_license_headers.py checks every tracked .py, .vhd, .vhd.in, .c and .h file for:

  • the MPL 2.0 notice, and
  • the copyright line Copyright (c) 2014-<year>, Lars Asplund lars.anders.asplund@gmail.com within the first 15 lines, with the current year as <year>, as in VUnit.

It lists each file with what is missing or outdated. The three files of the VHPI application (native/vhpi/) still said 2014-2023 and are updated here.

The year check means every file has to be bumped at the start of each year, and the check fails until then.

CI

A new lint workflow runs both on every push and pull request:

  • Ruff is pinned to 0.17.0, so a new release doesn't change the result, and its findings appear as annotations on the changed lines.
  • The header check runs even when ruff fails, so one run reports both.

Locally

pipx run ruff==0.17.0 check
python tools/check_license_headers.py

Tests

  • main passes ruff as it is, and the header check once the three VHPI headers are updated.
  • Ruff reports a deliberately broken file: an unused import (F401), an undefined name (F821) and trailing whitespace (W291).
  • The header check reports a file without a header, an outdated year and a different license notice, and accepts the Python, VHDL and C headers.

🤖 Generated with Claude Code

ru551n and others added 2 commits October 13, 2026 19:03
Check pyflakes and pycodestyle errors and warnings (E, F, W) with a
line length of 120, like black. The rules are listed explicitly and CI
pins the ruff version, so a new ruff release doesn't change what is
checked. The code passes as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/check_license_headers.py checks that every tracked Python, VHDL
and C source file has the MPL 2.0 notice and a copyright line ending
with the current year, and the lint workflow runs it after ruff. The
three files of the VHPI application still said 2014-2023.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ru551n ru551n changed the title Lint the Python code with ruff Lint the Python code with ruff and check license headers Oct 13, 2026
@ru551n
ru551n merged commit 204f357 into VUnit:main Oct 13, 2026
19 checks passed
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.

1 participant