Skip to content

impl pyrefly ignore #2207#2423

Open
asukaminato0721 wants to merge 6 commits intofacebook:mainfrom
asukaminato0721:2207-7
Open

impl pyrefly ignore #2207#2423
asukaminato0721 wants to merge 6 commits intofacebook:mainfrom
asukaminato0721:2207-7

Conversation

@asukaminato0721
Copy link
Contributor

@asukaminato0721 asukaminato0721 commented Feb 14, 2026

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.

@meta-cla meta-cla bot added the cla signed label Feb 14, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review February 14, 2026 17:57
Copilot AI review requested due to automatic review settings February 14, 2026 17:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_ignore quick-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.

Comment on lines 1934 to 1943
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);
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@github-actions

This comment has been minimized.

2 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@migeed-z
Copy link
Contributor

cc @maggiemoss

@meta-codesync
Copy link

meta-codesync bot commented Feb 17, 2026

@jvansch1 has imported this pull request. If you are a Meta employee, you can view this in D93480758.

@jvansch1 jvansch1 self-assigned this Feb 17, 2026
@github-actions

This comment has been minimized.

asukaminato0721 and others added 4 commits February 18, 2026 04:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Copy link
Contributor

@jvansch1 jvansch1 left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good to me. There is one outstanding question I would like @maggiemoss to weigh in on before fully approving this.

Copy link
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@github-actions
Copy link

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add codeactions (ignore error)

5 participants

Comments