-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Add code action to ignore diagnostic on the current line #21595
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
base: main
Are you sure you want to change the base?
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
b2cc26b to
7efe928
Compare
09ed5f7 to
517770c
Compare
|
6b9d27a to
52f3c3e
Compare
| [[profile.default.overrides]] | ||
| filter = 'binary(e2e)' | ||
| test-group = 'serial' | ||
|
|
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 think this is no longer needed, since I increased the request wait limit in e2e tests.
9d5de3a to
f519d8a
Compare
f519d8a to
1fe5c19
Compare
| + 2 # type: ignore | ||
| ``` | ||
|
|
||
| ## Interpolated strings |
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 didn't change the behavior for interpolated strings but I wrote this mdtest to document it, because it wasn't entirely clear to me when working on the fix.
| 2 | b = f""" | ||
| 3 | { | ||
| - a | ||
| 4 + a # ty:ignore[unresolved-reference] | ||
| 5 | } | ||
| 6 | more text | ||
| 7 | """ | ||
| "#); |
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.
Absolutely wild that this is valid syntax
| assert_snapshot!(test.code_actions(&UNRESOLVED_REFERENCE), @r" | ||
| info[code-action]: Ignore 'unresolved-reference' for this line | ||
| --> main.py:2:17 | ||
| | | ||
| 2 | b = a / 0 # ty:ignore[division-by-zero] some explanation | ||
| | ^ | ||
| | | ||
| 1 | | ||
| - b = a / 0 # ty:ignore[division-by-zero] some explanation | ||
| 2 + b = a / 0 # ty:ignore[division-by-zero] some explanation # ty:ignore[unresolved-reference] | ||
| 3 | | ||
| "); |
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.
Terrified of ever working on ruff
Summary
Add an LSP code action to suppress a diagnostic on the current line by inserting a new
ty:ignorecomment or extending the codes of an existingty:ignorecomment.ty: ignorecomments with a reason.Test Plan
This needs integration tests
Screen.Recording.2025-11-23.at.17.17.37.mov