Repository navigation
tests/test_naming_policy.py: bind the compared tuple to a name before asserting it, so Sonar's assertion-order rule stops misreading the literal-looking display as the expected side (#130) - #131
Conversation
… asserting it, so Sonar's assertion-order rule stops misreading the literal-looking display as the expected side (#130) python:S3415 was OPEN against one line in this file: `assert (found.family, found.role, found.also_matches) == expected` in `test_every_classified_name_keeps_its_exact_answer`. The rule's heuristic reads a parenthesised tuple display as a literal, so it read this line as "expected first" even though `found` is the classifier's actual output and `expected` is the parametrized table's expected value — the file's dominant, pytest-idiomatic order, already correct in substance. Naming the tuple `actual` before the comparison fixes the rule's misreading and, independent of Sonar, says in the code what the three attributes are being compared as, the same way `expected` already names the other side. A full manual pass over every `assert … == …` site in the file (133 total, wrapped continuations included) found no other minority-order site, so no other line changes. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 2 days and 15 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR updates one assertion in the exact-answer naming-policy test by naming the computed tuple File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
There was a problem hiding this comment.
🟢 Approval recommended
The focused change has no unresolved issues and preserves tested behavior.
Pull request overview
This test-only PR fixes a SonarCloud assertion-order false positive by naming the classifier tuple before comparison.
Changes:
- Binds the tuple to
actual. - Preserves the existing assertion behavior.
File summaries
| File | Description |
|---|---|
tests/test_naming_policy.py |
Names the classifier result tuple before asserting against expected. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…used in each tool's words as one behind a mark is, the compared pair of files is named before it is asserted, and the retyped refusal words are the finders' own (#1176) RV1188's review of #1188, from the head 024084b: SHOULD-1 (SonarCloud python:S3415, "Unify assertion argument order in this file"): the one assert with a bracketed tuple on the left was `assert (pin.read_bytes(), manifest.read_bytes()) == before`, the shape #131 (d682127) fixed. The pair is now bound to `now` and compared as `assert now == before`. Not `after`, which is a function in this file. Every other `==` assert has the value read on the left; the `in` asserts keep the text looked for on the left, as `in` reads. NIT-1: the module docstring, the row's docstring and the PR body said a space or a tab in front of the key was held "before a mark or after one", and the rows held no mark and one mark in front of it. A space or a tab in FRONT of a mark is now a row for each of the three files: refused unchanged by each tool's own code (update-pin-unrecognised, update-manifest-no-shape, bump-leg-pin-unrecognised), as the reader refuses it. Six rows more (126 in all), and the places are named in LEAD_PLACES. NIT-3: the two end-to-end refusal rows retyped "has 0 `commit` line(s)"; they now use FINDERS["shape-pin-commit"].refused and FINDERS["leg-pin-commit"].refused, as the in-process rows do. The tools are untouched. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>



Lane: openreposhape-2 (openRepoShape-2)
Claim: #130 (comment)
Closes #130.
What was wrong
SonarCloud
python:S3415was OPEN againsttests/test_naming_policy.py(issue
AaCLcrLfNM_GaF89pHsJ, re-analysed at 50d4078 on2026-09-12T01:10:34Z), naming one line as "Expected value first" against
130+ "Actual value first" sites elsewhere in the file (the dominant,
pytest-idiomatic convention: actual/computed value on the left of
==,expected value on the right):
tests/test_naming_policy.py:1285Sonar's heuristic reads the parenthesised tuple display on the left as
a literal, and the bare name
expectedon the right as the actual value— backwards for this line.
foundis the value the classifier undertest produced;
(found.family, found.role, found.also_matches)is theactual value, and
expectedis the row from theKEEPS_ITS_ANSWERparametrize table the test expects it to equal. The line already asserts
in the file's dominant order semantically; only its syntax fooled the
rule.
A full manual pass over every
assert … == …site in the file (133total, including wrapped continuations) found no other minority-order
site.
What landed
tests/test_naming_policy.py,test_every_classified_name_keeps_its_exact_answer:assert found is not None, f"{name} classified as nothing" - assert (found.family, found.role, found.also_matches) == expected + actual = (found.family, found.role, found.also_matches) + assert actual == expectedBinding the tuple to
actualfixes Sonar's misreading (the left side isnow a bare name) and, independent of Sonar, names what the three
attributes are being compared as — the same way
expectedalready namesthe other side. No pinned/digest-copied file is touched.
How it was proven
python3 -m pytest -q tests/test_naming_policy.py— 162 passed.tests/test_[a-m]*.py— 366 passed, 1 skipped (the known flake).tests/test_[n-z]*.py— 770 passed.🤖 Generated with Claude Code
Summary by Sourcery
Enhancements: