-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Make rendering of fix diffs more concise #26161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
42ee9cf
22df38a
efabdbe
4ecca7f
c8870d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,10 @@ exit_code: 1 | |
| ----- stdout ----- | ||
| unformatted: File would be reformatted | ||
| --> input.py:1:1 | ||
| | | ||
| - | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E.g. this diff is not very useful anymore. We could as well omit it |
||
| 1 | from test import say_hy | ||
| 2 | | ||
| 3 | if __name__ == "__main__": | ||
| | | ||
|
|
||
| 1 file would be reformatted | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,10 +26,10 @@ unused-import: [*] `os` imported but unused | |
| 3 | match 42: # invalid-syntax | ||
| | | ||
| help: Remove unused import: `os` | ||
| | | ||
| - import os # F401 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, why are we omitting line numbers now? Oh, is it because the diff shows the line numbers after applying the fix. Hmm, this is somewhat surprising to me (@ntBre). Without line numbers, the diff doesn't feel very useful to me anymore
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which line number would we display here? I believe we went with the new line number to avoid both the old approach of showing both (e.g. I'd have to look at the code again, but from what I remember I think it might be tricky to detect that we're in this situation (no relevant context and only a deletion). |
||
| 1 | x = y # F821 | ||
| 2 | match 42: # invalid-syntax | ||
| 3 | case _: ... | ||
| | | ||
|
|
||
| undefined-name: Undefined name `y` | ||
| --> input.py:2:5 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we now retaining more lines here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a 1-row gutter around fix-diff hunks. This is similar to what we do for our diagnostic annotations, and was again inspired by what rustc does for its fix diffs. Here's what rustc does:
rustc diff suggestion
It allows the fix diff to "breathe" a little bit by adding a little bit of padding below the
helpmessage, making the rendering look less cluttered. I found the "cluttered" issue was especially a problem with a small context window. Here's an example diff rendering on this PR currently:Current rendering with the gutter
and I could make this change to the PR:
Patch
which would make the same diagnostic look like this, which I find to still be an improvement over
main, but looks a bit cluttered to my eyes:Rendering without the gutter