Repository navigation
build: ruff, Dependabot and a PR labeler - #33
Merged
Merged
Conversation
Use a line length of 88, which the code already follows, and take the target version (3.11) from requires-python. Select E, W, F, I, UP and B explicitly. ruff 0.17 enables about 400 rules when nothing is selected, and that default set changes between releases, so an explicit list keeps the result stable when ruff is updated. Ignore E501 only: ruff format wraps code at 88 columns, and the long lines it leaves are prose in strings and comments.
These tests pass on the current code and must keep passing after the ruff clean-up: - the public names of the complexnn package and of `from complexnn import *`, including the fft and utils submodules - ComplexBN and ComplexLayerNorm reject an input of unknown rank with ValueError - ComplexDense output, computed with numpy; the layer multiplies by the conjugate of its kernel, unlike ComplexConv - ComplexConv1D/2D with spectral_parametrization=True raise NotImplementedError, from the ifft stubs in conv.py
ruff reported every re-export in complexnn/__init__.py as an unused import (F401). List them in __all__ instead, which also documents the public API. __all__ keeps `from complexnn import *` exactly as it was, so it includes the fft and utils submodules. fft was only loaded as a side effect of an import in conv.py that the next commit removes, so import both submodules explicitly here.
- conv.py imported fft, fft2, ifft and ifft2 from .fft but used none of them: the module defines its own ifft and ifft2 stubs, which shadow the imports (F401, F811). The stubs stay, so spectral parametrisation still raises NotImplementedError. - ComplexBatchNormalization.build and ComplexLayerNorm.build computed `ndim = len(input_shape)` and never used it (F841). For an input of unknown rank, len() raised ValueError; the layer's own check for an undefined channel dimension now raises ValueError instead. - ComplexDense.call sliced the input into real and imaginary parts and never used the slices (F841). InputSpec(ndim=2) already guarantees that the slicing could not fail, so the output is unchanged. The tests added earlier cover each of these paths.
conv_utils, the helper module that replaced TensorFlow's private copy, is a submodule like utils and fft, so it is imported and listed with them instead of appearing as a side effect of importing conv.
Add the ruff-check (with --fix) and ruff-format hooks from astral-sh/ruff-pre-commit v0.17.0 after the existing read-only hooks, which stay as they were. Both hooks read the settings in pyproject.toml. The lint hook runs first, as the ruff-pre-commit README asks when fixes are enabled. pre-commit.ci already runs this file on the repository, so it will now also apply ruff fixes to pull requests.
The lint job ran flake8 for syntax errors and undefined names only. Run `ruff check` and `ruff format --check --diff` instead. Both use the settings in pyproject.toml, and ruff check reports findings as GitHub annotations. The job reads the ruff version from the ruff-pre-commit rev in .pre-commit-config.yaml, so CI and the hooks cannot drift apart when pre-commit.ci updates the pin. A comment next to the rev says so. The step fails if it cannot find the version.
Adapted from the github-files template that #25 would add. Both ecosystems update monthly instead of daily, with one grouped pull request per ecosystem, which suits a library that only needs to keep working. The pip entry watches pyproject.toml and docs/requirements.txt with versioning-strategy increase-if-necessary, so Dependabot never raises the tensorflow>=2.15 lower bound that Keras 2 users depend on. The GitHub Actions entry will also propose replacing the unsupported github/codeql-action@v2 in codeql.yml (only v3 and v4 are supported).
Take .github/labeler.yml and .github/workflows/labeler.yml unchanged from JesperDramsch/github-files, as #25 would. Keeping them identical to the template lets the github-files "label sync" group keep updating this repository without overwriting anything specific to it. The workflow runs actions/labeler v7.0.0 on pull_request_target with pull-requests: write and never checks out the pull request's code. actions/labeler v7 only understands changed-files, head-branch and base-branch, so the template's title and body rules for the "breaking" label are logged as unknown and that label is never applied. That needs fixing in the template, not here.
JesperDramsch
force-pushed
the
stage2/tooling
branch
from
October 12, 2026 18:53
35a7bc4 to
d4e818c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 2, PR 4 of 4. ruff for linting and formatting, Dependabot, a PR labeler, and the useful parts of the sync bot's #25.
What changes
ruff is configured in
pyproject.tomlwith line length 88, matching the existing code. It runs from pre-commit, and CI's lint job usesruff checkandruff format --checkinstead of the flake8 critical check.Lint fixes.
ruff check --fixandruff formateach have their own commit. Before them:complexnn.__all__declares the package namespace;The two style commits come before the commits that enforce linting, so every commit from there on passes the lint job it introduces.
Dependabot checks GitHub Actions and pip monthly, grouped per ecosystem. The pip entry opens no PRs while the requirements are bare lower bounds; the comment in
dependabot.ymlexplains this.Labeler labels PRs by the files they change.
About #25
#25 syncs 38 files from
JesperDramsch/github-files. Taken as is, it would replace the newpublish.yml(trusted publishing),test_python.yml,pyproject.tomland README, bring backrequirements.txt, and reformat the sources. This PR ports only the parts that help: the Dependabot, labeler and ruff configuration. Closing #25 afterwards still leaves the sync bot, which would reopen it. That needs a change on the github-files side, excluding this repository's customised files from the sync.Verification
On the branch, rebuilt on main after #30, #31 and #32:
ruff check .is clean.-Wpasses.style: apply ruff formaton passes the lint job.Merge notes
The branch was rebuilt on the current main instead of merged, so the history was force-pushed:
ruff check --fixandruff formaton today's main.72f2fecaddsconv_utils, the helper module from refactor: public Keras APIs only, no input_shape warnings #30, tocomplexnn.__all__and to the namespace test.The other commits are the same changes as before.