Move fix suggestion to subdiagnostic by ntBre · Pull Request #19464 · astral-sh/ruff (original) (raw)
added internal
An internal refactor or improvement
Related to reporting of diagnostics.
labels
ntBre marked this pull request as ready for review
Summary
This PR tweaks Ruff's internal usage of the new diagnostic model to more closely
match the intended use, as I understand it. Specifically, it moves the fix/help
suggestion from the primary annotation's message to a subdiagnostic. In turn, it
adds the secondary/noqa code as the new primary annotation message. As shown in
the new ruff_db tests, this more closely mirrors Ruff's current diagnostic
output.
I also added Severity::Help to render the fix suggestion with a help: prefix
instead of info:.
These changes don't have any external impact now but should help a bit with
Test Plan
New full output format tests in ruff_db
the idea here is that NoqaCode::display is the expensive step and this basically reduces it to cloning a string instead of reformatting the noqa code
ntBre deleted the brent/new-diagnostic-suggestion branch
ntBre added a commit that referenced this pull request
dcreager added a commit that referenced this pull request
- main: (76 commits)
Move fix suggestion to subdiagnostic (#19464)
[ty] Implement non-stdlib stub mapping for classes and functions (#19471)
[ty] Disallow illegal uses of
ClassVar(#19483) [ty] DisallowFinalin function parameter/return-type annotations (#19480) [ty] ExtendFinaltest suite (#19476) [ty] Minor change to diagnostic message for invalid Literal uses (#19482) [ty] Detect illegal non-enum attribute accesses in Literal annotation (#19477) [ty] Reduce size ofTypeInference(#19435) Run MD tests for Markdown-only changes (#19479) Revert "[ty] Detect illegal non-enum attribute accesses in Literal annotation" [ty] Detect illegal non-enum attribute accesses in Literal annotation [ty] Added semantic token support for more identifiers (#19473) [ty] Make tuple subclass constructors sound (#19469) [ty] Pass down specialization to generic dataclass bases (#19472) [ty] Garbage-collect reachability constraints (#19414) [ty] Implicit instance attributes declaredFinal(#19462) [ty] Expansion of enums into unions of literals (#19382) [ty] Avoid rechecking the entire project when changing the opened files (#19463) [ty] Add warning for unknownTY_MEMORY_REPORTvalue (#19465) [ty] Sync vendored typeshed stubs (#19461) ...
dcreager added a commit that referenced this pull request
- main:
[ty] Use
ThinVecfor sub segments inPlaceExpr(#19470) [ty] Splat variadic arguments into parameter list (#18996) [flake8-pyi] Skip fix if allUnionmembers areNone(PYI016) (#19416) Skip notebook with errors in ecosystem check (#19491) [ty] Consistent use of American english (in rules) (#19488) [ty] Support iterating over enums (#19486) Fix panic for illegalLiteral[…]annotations with inner subscript expressions (#19489) Move fix suggestion to subdiagnostic (#19464) [ty] Implement non-stdlib stub mapping for classes and functions (#19471) [ty] Disallow illegal uses ofClassVar(#19483) [ty] DisallowFinalin function parameter/return-type annotations (#19480) [ty] ExtendFinaltest suite (#19476) [ty] Minor change to diagnostic message for invalid Literal uses (#19482) [ty] Detect illegal non-enum attribute accesses in Literal annotation (#19477) [ty] Reduce size ofTypeInference(#19435) Run MD tests for Markdown-only changes (#19479) Revert "[ty] Detect illegal non-enum attribute accesses in Literal annotation" [ty] Detect illegal non-enum attribute accesses in Literal annotation [ty] Added semantic token support for more identifiers (#19473) [ty] Make tuple subclass constructors sound (#19469)
UnboundVariable pushed a commit to UnboundVariable/ruff that referenced this pull request
- main: (28 commits)
[ty] highlight the argument in
static_asserterror messages (astral-sh#19426) [ty] Infer single-valuedness for enums based onint/str(astral-sh#19510) [ty] Restructure submodule query aroundFiledependency [ty] MakeModulea Salsa ingredient [ty] Reachability analysis forisinstance(…)branches (astral-sh#19503) [ty] Normalize single-member enums to their instance type (astral-sh#19502) [ty] Invertty_ideandty_projectdependency (astral-sh#19501) [ty] Implement mock language server for testing (astral-sh#19391) [ty] Detect enums if metaclass is a subtype of EnumType/EnumMeta (astral-sh#19481) [ty] perform type narrowing for places markedglobaltoo (astral-sh#19381) [ty] UseThinVecfor sub segments inPlaceExpr(astral-sh#19470) [ty] Splat variadic arguments into parameter list (astral-sh#18996) [flake8-pyi] Skip fix if allUnionmembers areNone(PYI016) (astral-sh#19416) Skip notebook with errors in ecosystem check (astral-sh#19491) [ty] Consistent use of American english (in rules) (astral-sh#19488) [ty] Support iterating over enums (astral-sh#19486) Fix panic for illegalLiteral[…]annotations with inner subscript expressions (astral-sh#19489) Move fix suggestion to subdiagnostic (astral-sh#19464) [ty] Implement non-stdlib stub mapping for classes and functions (astral-sh#19471) [ty] Disallow illegal uses ofClassVar(astral-sh#19483) ...
Conflicts:
crates/ty_ide/src/goto.rs
KotlinIsland pushed a commit to KotlinIsland/basedpython that referenced this pull request
Summary
This PR tweaks Ruff's internal usage of the new diagnostic model to more
closely
match the intended use, as I understand it. Specifically, it moves the
fix/help
suggestion from the primary annotation's message to a subdiagnostic. In
turn, it
adds the secondary/noqa code as the new primary annotation message. As
shown in
the new ruff_db tests, this more closely mirrors Ruff's current
diagnostic
output.
I also added Severity::Help to render the fix suggestion with a
help: prefix
instead of info:.
These changes don't have any external impact now but should help a bit with #19415.
Test Plan
New full output format tests in ruff_db
Rendered Diagnostics
Full diagnostic output from annotate-snippets in this PR:
error[unused-import]: `os` imported but unused
--> fib.py:1:8
|
1 | import os
| ^^
|
help: Remove unused import: `os`Current Ruff output for the same code:
fib.py:1:8: F401 [*] `os` imported but unused
|
1 | import os
| ^^ F401
|
= help: Remove unused import: `os`Proposed final output after #19415:
F401 [*] `os` imported but unused
--> fib.py:1:8
|
1 | import os
| ^^
|
help: Remove unused import: `os`These are slightly updated from astral-sh/ruff#19464 (comment) below to remove the extra noqa codes in the primary annotation messages for the first and third cases.
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
[ Show hidden characters]({{ revealButtonHref }})