Skip to content

Switch db to ruff_annotate_snippets' suggestions - #27576

Draft
epage wants to merge 2 commits into
astral-sh:mainfrom
epage:snapshots
Draft

Switch db to ruff_annotate_snippets' suggestions#27576
epage wants to merge 2 commits into
astral-sh:mainfrom
epage:snapshots

Conversation

@epage

@epage epage commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Motivations

  • Unblocks unicode renderer (and no-graphics in the future)
  • Removes the other use case for hidden_snippets, unblocking it from going back to file-level, allowing us to use Origin, and remove one more patch on top of upstream
  • Provides fancier diff renderings
  • Reduces our dedicated code, with everything sharing in improvements

Test Plan

Comment on lines -18 to +23
--> input.py:1:1
|
-
1 | from test import say_hy
|
--> input.py:1:1
|
1 | from test import say_hy
2 |
3 | if __name__ == "__main__":
4 | say_hy("dear Ruff contributor")
|

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of one of the bugs I need to work through

|
- import os # F401
1 | x = y # F821
1 - import os # F401

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendering difference: removed lines still count towards the line numbers

@astral-sh-bot

astral-sh-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 96.96%. The percentage of expected errors that received a diagnostic held steady at 92.96%. The number of fully passing files held steady at 106/133.

Comment on lines -59 to 63
--> bar.py:1:7
|
- bar = "needs formatting"
1 + bar = "needs formatting"
|
--> bar.py:1:7
|
1 | bar = "needs formatting"
| ~~~~~~~~~~~~~~~~~~

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~ is the symbol for "added and removed". In unicode, it uses ±. I could hack that in our "ascii" renderer since it is already a hybrid unicode/ascii renderer until we get proper unicode support

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, I think in this particular use of ± is a mistake. annotate-snippets assumes that suggestions are in context of an existing snippet. When making formatting changes like this, the suggestion is the annotation and i should never be rendered with ±, only + or full diffs.

@astral-sh-bot

astral-sh-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

::: cell 3:0:1
|
- import sys
0 - import sys

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendering difference: we are showing the full location for cells. This was trying to compromise between our current output and annotate snippets

@astral-sh-bot

astral-sh-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

Comment on lines -1947 to 1948
--> -:1:1
--> -:1:1
|
1 + # fix from stable-test-rule-safe-fix
|

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently we have an alignment bug

Comment on lines -1027 to 866
6 | line 6
- line 7
7 + fixed line 7
8 | line 8
|
7 | fixed line 7
| +++++
note: This is an unsafe fix and may change runtime behavior

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is showing a pure-insertion happened, rather than having to fallback to a full diff

Comment on lines +916 to +924
2 ~ fixed line 2
3 | line 3
6 | line 6
7 ~ fixed line 7
8 | line 8
12 | line 12
- line 13
13 + fixed line 13
13 ~ fixed line 13

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotate-snippets doesn't recognize a pure-insertions when there are multiple patches being applied. I figured this is fine because this is a bit of a contrived test case.

@astral-sh-bot

astral-sh-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant