[primer] Show changed messages as diffs instead of removed+added#10914
Draft
Pierre-Sassoulas wants to merge 8 commits intopylint-dev:mainfrom
Draft
[primer] Show changed messages as diffs instead of removed+added#10914Pierre-Sassoulas wants to merge 8 commits intopylint-dev:mainfrom
Pierre-Sassoulas wants to merge 8 commits intopylint-dev:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10914 +/- ##
==========================================
+ Coverage 96.19% 96.22% +0.02%
==========================================
Files 178 178
Lines 19683 19778 +95
==========================================
+ Hits 18934 19031 +97
+ Misses 749 747 -2
🚀 New features to boost your workflow:
|
DanielNoord
reviewed
Mar 10, 2026
Collaborator
DanielNoord
left a comment
There was a problem hiding this comment.
Is this really better? It seems like a lot of code for very minimal gain?
Perhaps better suggestion would be to show the changes based on position instead of message name? That should catch most "message was slightly changed" cases in a simple overview without the fuzzy matching being necessary
Member
Author
|
Right, I'm going to reuse the comparator PR from earlier too. |
This was referenced Mar 16, 2026
d1083e2 to
c819028
Compare
This comment has been minimized.
This comment has been minimized.
c819028 to
c5c3e01
Compare
This comment has been minimized.
This comment has been minimized.
ef031be to
3edeef0
Compare
3edeef0 to
80285ff
Compare
This comment has been minimized.
This comment has been minimized.
80285ff to
995984c
Compare
This comment has been minimized.
This comment has been minimized.
995984c to
f741439
Compare
This comment has been minimized.
This comment has been minimized.
f741439 to
546b930
Compare
This comment has been minimized.
This comment has been minimized.
546b930 to
f58d4c5
Compare
This comment has been minimized.
This comment has been minimized.
Instead of reporting a moved or reworded diagnostic as a separate removal + addition, pair messages that share the same (symbol, path, obj) key and report them as "changed" with a human-readable diff. Comparator.__iter__ now yields 4-tuples (package, missing, new, changed) and exposes a commits dict. Short field changes (type, confidence) use an inline format; long message strings get a diff block with caret hints highlighting the changed spans.
New messages are now sorted into subcategories: - useless-suppression → "fixed false positives" (🎉) - locally-disabled → "introduced false positives" (😞) - astroid-error → counted separately - everything else → "now emitted" Extract _ClassifiedMessages and _format_messages helpers, and use _details_section for consistent <details> blocks with the blank line required for GitHub markdown rendering.
- format_span now returns `line:col`-`endLine:endCol` spans, and
message_diff says "Moved from {old} to {new}" — avoids ambiguity
between span-range and movement.
- message_diff iterates set(old) | set(new) so keys present only in
new are also detected.
Adds fixtures and unit tests that bring coverage on comparator.py and primer_compare_command.py to 100% — all message-classification branches (astroid-error, useless-suppression fix, locally-disabled FP, genuine new message) and both truncation code paths (multi-package iteration break and no-space fallback) now have dedicated tests.
… helpers Pass ``ChangedMessage`` to ``message_diff`` directly so callers don't have to unpack ``(old, new)`` at every site. Rename ``_match_residuals`` to ``_pair_by_position`` — it advertises what the helper does rather than what it consumes. Split the collapsed ``_create_comment_for_package`` back into focused ``_format_changed_messages`` / ``_format_new_messages`` / ``_format_missing_messages`` helpers, with a small ``_source_link_for`` factory for the per-package closure. Drops the ``_ClassifiedMessages`` side-car class; classification lives inline in the new-messages formatter it belongs to. Also swap "diagnostic" for "message"/"warning" in docstrings and comments to match pylint's own terminology.
Bucket only the *new* side and walk ``old_residuals`` once, popping from each matching bucket. That removes the dual ``old_by_key`` dictionary and the ``paired_old_ids`` / ``paired_new_ids`` shadow bookkeeping — we can build ``final_missing`` inline in the old-side walk, and ``final_new`` still reads from the untouched input list.
Adds a second pairing pass keyed on exact source location, gated on ``SequenceMatcher.ratio() >= 0.5`` between the old and new symbols. This catches renames like ``used-before-assignment`` → ``possibly-used-before-assignment`` and reports them as one *changed* message instead of a separate removal + addition. The similarity gate avoids pairing unrelated messages that happen to coincide on the same line (e.g. ``useless-suppression`` removed and ``locally-disabled`` added at the same position).
f58d4c5 to
6e7d3c9
Compare
A ``locally-disabled`` message is emitted from a ``# pylint: disable=`` comment in the source. Since the primer pins each repository to a fixed commit, the disable comments are identical between the main and PR runs, so the original "new locally-disabled = newly-introduced false positive" assumption never fires in practice — and a maintainer upgrading pylint would clean those up anyway. Drop the dedicated bucket and let any new ``locally-disabled`` fall through to the generic *New messages* section.
Contributor
|
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 47eda50 |
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.
Type of Changes
Description
Instead of reporting moved or reworded diagnostics as separate removal + addition, the primer comparator now pairs residual messages by (symbol, path, obj) and shows a compact diff of what changed.
Rendering improvements:
Details
wrappingTest infrastructure:
Details
block