On Ruff rules #813
Replies: 3 comments 11 replies
|
The very first one that I have come across recently is the Please comment below or react with an emoji if this is worth keeping? |
|
Currently, ruff complains about the license headers. (Reported by reviewed only for new files.) |
|
Do we intentionally use the Generally, no. The workflow also installs unpinned Ruff: pip install ruffRecommended: pip install ruff==<approved-version>
ruff format src/ --check --output-format=rdjsonUse |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Given that we have begun to use
ruffas a linter viareviewdog, this discussion will be used to iron out which rules are worth implementing and which ones are worth ignoring.In general, when you are working on a PR and
reviewdogflags someruffissues, a large number of the flagged errors can be auto-fixed only for the files you are working on.It is also advised that you only run
ruffon the files you have changed in your PR. Globalruffautofix will flag pre-existing issues in unrelated files viareviewdog, forcing each PR to either expand scope to fix unrelated code or ignore the warnings (not preferred). That's a downward spiral: every cycle will bloat PRs unnecessarily.For example, if you are making some changes to
some_file.py,ruffas a linter viaruff check some_file.pyruffas a formatter viaruff format some_file.py--fixflag i.e.ruff check --fix some_file.pyorruff format --check some_file.pyAs always, additional details are available in the
ruffdocumentation: https://docs.astral.sh/ruff/linter/ and https://docs.astral.sh/ruff/formatter/Running mypy on only the files you changed
The same principle applies to
mypy: run it only on the files you've changed in your PR. Themypyjob in thereviewdogworkflow already uses-filter-mode=added, so it only fails on type errors that appear on newly added lines. But the codebase is largely untyped andsrc/currently contains hundreds of pre-existingmypyfindings, so runningmypyagainst all ofsrc/locally produces noise that can obscure the errors actually introduced by your change.To check only the files you touched:
Note that
mypyfollows imports and will still type-check referenced modules, so an error may surface in an imported file rather than the one you edited. Because the workflow filters to added lines, only type errors on lines you actually added (or modified) will fail CI. Pre-existing issues in unrelated files are left alone, keeping each PR scoped to its own changes.As always, additional details are available in the mypy documentation: https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html
@eclipse-qrisp/technology-qrisp-committers @eclipse-qrisp/technology-qrisp-contributors
All reactions