build: broaden the ruff rule set and lint conanfile.py - #66
Merged
Conversation
ruff.toml set only line-length, leaving ruff at its default E4,E7,E9,F, so import order, obsolete syntax, and common bug patterns went unchecked while clang-tidy ran with nearly everything enabled. Select E,F,I,UP,B,SIM,RUF,ANN so both languages are held to comparable standards. ANN already passes and keeps the scripts' annotations from rotting. conanfile.py was neither linted nor formatted, because PYTHON_SOURCES covered scripts/ only. Add it. ruff format already agrees with the file, so this brings no churn. RUF012 and ANN are ignored there: Conan reads options and default_options off the recipe class, and calls its methods through an untyped API. known-third-party = ["conan"] is load-bearing rather than cosmetic. The repository's conan/ directory shadows the package name, so isort's src detection treats `from conan import ConanFile` as first-party and splits it away from the conan.tools imports it belongs with. Confirmed by running the same file in a directory with and without a conan/ present. Without this setting, enabling I would reorder the recipe's imports and lock in the worse grouping. The only code change is rename.py's import block.
megabyde
force-pushed
the
build/broaden-ruff-rules
branch
from
July 26, 2026 06:05
db46a41 to
1334444
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.
Problem
ruff.tomlset onlyline-length, so ruff ran at its defaultE4,E7,E9,Fwhile clang-tidy ran withbugprone-*,misc-*,modernize-*,performance-*, andreadability-*all as errors. Importorder, obsolete syntax, and common bug patterns went unchecked.
Separately,
conanfile.pywas neither linted nor formatted:PYTHON_SOURCEScoveredscripts/only.Fix
Select
E,F,I,UP,B,SIM,RUF,ANN, and addconanfile.pytoPYTHON_SOURCES.ruff formatalreadyagrees with that file, so it brings no churn.
The trap, and why
known-third-partyis load-bearingEnabling
Inaively makes the recipe worse. The repo'sconan/directory (it holdssettings_user.yml) shadows theconanpackage name, so isort's src detection classifiesfrom conan import ConanFileas first-party and splits it away from its siblings:Confirmed by running the identical file in a scratch directory with and without a
conan/present:without it ruff reports the imports already correct, with it ruff produces the split above.
known-third-party = ["conan"]restores the correct grouping, and as a resultconanfile.pyisuntouched by this PR. Flagging it because a future reader could reasonably delete that setting as
redundant.
Choices worth a second opinion
ANNis included. It already passes onscripts/, so it costs nothing today and keeps theexisting annotations from rotting. Ignored for
conanfile.py, whose methods are Conan callbacksreached through an untyped API. Happy to drop it.
RUF012ignored forconanfile.py— it flagsoptions/default_optionsand suggestsClassVaror__init__; neither applies, since Conan reads them off the class.D(docstrings) left out — it wants 5 more docstrings on short helpers, which read as noise.Verification
ruff checkandruff format --checkclean overscripts/andconanfile.pymake lintandmake format-checkboth exit 0conanfile.pybyte-identical to mainconan installexits 0 andconan inspectresolvesversion: 0.1.0, soset_version()still parsesCMakeLists.txtrename.py's import blockScope
Half of the test/lint-depth work item. The branch-coverage floor is not here: measuring it turned up
evidence that changes the recommendation, so it needs a decision rather than a quiet bundling.