[DISCUSS] Disable magic value linter for tests?
Metadata
Current evaluation
Resolved by merged PR canonical/starbase#151 (commit 073e450), adding PLR2004 ignores for tests. PR #150 also disabled private-member linting in tests.
Resolution: closed resolved
Reason: PR #151 was merged into main and fixed #148 by exempting tests from Ruff’s PLR2004 magic-value comparison rule. The additional private-member test exemption discussed in the issue was merged separately in PR #150.
Evaluated by: mr-cal-bot
No scores available.
Issue body
We fairly frequently compare to literals in tests, which means [PLR2004](https://docs.astral.sh/ruff/rules/magic-value-comparison/) linter complains a lot. Would anyone object to disabling this in tests?
Example PR with a lot of this: https://github.com/canonical/craft-parts/pull/574/files
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Resolved by merged PR canonical/starbase#151 (commit 073e450), adding PLR2004 ignores for tests. PR #150 also disabled private-member linting in tests. | |
| stealth/space-bunny-alpha | — | closed resolved | Resolved: Ruff's PLR2004 magic-value comparison and SLF private/protected-member rules were disabled for tests via the test per-file ignores. | |
| qwen/qwen3.6-35b-a3b | — | — | Resolved. The PLR2004 magic value comparison rule will be disabled for test files. The private/protected method usage rule was also disabled for tests. | |
| qwen/qwen3.6-35b-a3b | — | — | Maintainers agreed to disable the magic value comparison linter rule for tests. Implementation was confirmed, also extending the configuration to suppress warnings for private and protected method usage in test files. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved after agreement to disable the PLR2004 magic value comparison linter rule for tests. The private/protected method access rule will also be disabled in test directories. Implementation planned. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/starbase#151
(confidence 100%)
Merged PR resolving #148 via commit 073e450.
-
Likely Fixed By:
canonical/starbase#150
(confidence 98%)
Merged the related private/protected-member lint exemption requested in #148’s final comment.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #151 style(lint): disable magic value check in tests | starbase | merged | Merged #151 as commit 073e450, adding a test-only Ruff ignore for PLR2004 so magic values are allowed in tests; fixes #148. | |
| #351 linters: add PLR2004 to ruff ignore | craft-parts | merged | Merged PR #351 added PLR2004 to Ruff's test ignores, suppressing over 600 magic-value warnings. Landed as commit 517f95d8. |