Skip to content

Use Annotation::tags instead of hardcoded rule matching in ruff server#20565

Merged
MichaReiser merged 3 commits intoastral-sh:mainfrom
danparizher:fix-20532
Sep 26, 2025
Merged

Use Annotation::tags instead of hardcoded rule matching in ruff server#20565
MichaReiser merged 3 commits intoastral-sh:mainfrom
danparizher:fix-20532

Conversation

@danparizher
Copy link
Contributor

Summary

Fixes #20532

Test Plan

Tested the specific rules by creating a test file, verified the rules are still identified

@github-actions
Copy link
Contributor

github-actions bot commented Sep 25, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Thank you

The changes in the diagnostic generation code look correct to me but we also need to set the tags when creating the F401, F841, and RUF059 diagnostics, similar to how we do it for deprecated in ty

diag.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);

That also makes me believe that you used the Ruff version bundled with VS code (or local to your project) when testing the change.

To test the change, set the ruff.path setting in VS Code to <ruff_repository>/target/debug/ruff. You then need to build ruff with cargo build --bin ruff and restart (or reload) VS Code.

There are two things you can do to verify your test setup is working as expected:

  1. Add a tracing::warn!("Hy from Ruff"); to the tags function. You should see this message in Ruff's output panel (if it is using the correct version)
  2. F401 etc. shouldn't be highlighted as Unnecessary with the version from this PR.

@MichaReiser MichaReiser added internal An internal refactor or improvement server Related to the LSP server labels Sep 25, 2025
@danparizher
Copy link
Contributor Author

Thanks for the tips, I'll try these out today!

@danparizher
Copy link
Contributor Author

I was able to test it out with the config you suggested and added the tags in. Let me know if it looks good and if you get the same results!

@MichaReiser MichaReiser merged commit 0bae7e6 into astral-sh:main Sep 26, 2025
35 checks passed
@MichaReiser
Copy link
Member

Thank you. This is looking great.

@danparizher danparizher deleted the fix-20532 branch September 26, 2025 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement server Related to the LSP server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use Annotation::tags instead of hard coding the rules in ruff server

2 participants