Conversation
There was a problem hiding this comment.
Pull request overview
Adds an LSP quick-fix code action to insert # pyrefly: ignore [error-code], including merging the new code into an existing # pyrefly: ignore [...] on the same line (and supporting an above-line merge path in the implementation).
Changes:
- Introduce
pyrefly_ignorequick-fix module to generate an “Add# pyrefly: ignore [...]” code action (with merge behavior). - Wire the new quick-fix into
Transaction::local_quickfix_code_actions_sorted. - Add LSP code-action tests for inline insertion and same-line merge behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pyrefly/lib/test/lsp/code_actions.rs |
Adds snapshot tests for the new ignore quick-fix behavior. |
pyrefly/lib/state/lsp/quick_fixes/pyrefly_ignore.rs |
Implements detection/merge/insert logic for # pyrefly: ignore [code] quick-fix edits. |
pyrefly/lib/state/lsp/quick_fixes/mod.rs |
Exposes the new pyrefly_ignore quick-fix module. |
pyrefly/lib/state/lsp.rs |
Integrates the new ignore quick-fix into the existing local quick-fix code-action collection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let error_range = error.range(); | ||
| if error_range.contains_range(range) | ||
| && let Some(action) = quick_fixes::pyrefly_ignore::add_pyrefly_ignore_code_action( | ||
| &module_info, | ||
| &error, | ||
| ) | ||
| && !other_actions.iter().any(|existing| existing == &action) | ||
| { | ||
| other_actions.push(action); | ||
| } |
There was a problem hiding this comment.
This change adds the Add # pyrefly: ignore [...] quick-fix for any error under the cursor, including UnknownName. Several existing LSP code-action snapshot tests in pyrefly/lib/test/lsp/code_actions.rs still expect only import/generate actions for unknown-name scenarios (e.g. basic_test), so they will now also need to include the new ignore action (or explicitly filter it) to keep the suite passing.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
cc @maggiemoss |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ea4e0b1 to
8132838
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Overall looks pretty good to me. There is one outstanding question I would like @maggiemoss to weigh in on before fully approving this.
kinto0
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Summary
Fixes part of #2207
fix #675
Added a quick fix that inserts # pyrefly: ignore [error-code], merging into an existing pyrefly ignore on the same line or comment-only line above when present.
Test Plan
Added LSP code action tests covering insertion and merge behavior.