Skip to content

Let unused-ignore in a suppression opt out of unused-ignore reporting#3957

Open
kz357 wants to merge 1 commit into
facebook:mainfrom
kz357:fix/issue-3951-suppress-unused-ignore
Open

Let unused-ignore in a suppression opt out of unused-ignore reporting#3957
kz357 wants to merge 1 commit into
facebook:mainfrom
kz357:fix/issue-3951-suppress-unused-ignore

Conversation

@kz357

@kz357 kz357 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

A # pyrefly: ignore[...] comment that lists unused-ignore is now not itself reported as unused, and listing it suppresses the unused-ignore diagnostic for that comment. This lets a single comment cover code that errors on one Python version but not another (used on one, unused on other) without dead-ending, matching mypy/ty.

Normal unused comment that doesn't explicitly list unused-ignore is still reported.

Fixes #3951

Test Plan

4 unit tests in pyrefly/lib/state/errors.rs
cargo test -p pyrefly --lib unused_ignore

  • test_unused_ignore_listed_with_used_code -- not flagged when error present
  • test_unused_ignore_listed_suppresses_comment -- not flagged when error absent
  • test_unused_ignore_alone_not_flagged -- bare [unused-ignore] doesn't self-flag
  • test_unused_ignore_without_listing_still_flagged -- regression guard, normal comment still reported

cargo fmt and cargo clippy run fine

A `# pyrefly: ignore[...]` comment that lists `unused-ignore` is now not itself reported as unused, and listing it suppresses the unused-ignore diagnostic for that comment. This lets a single comment cover code that errors on one Python vrsion but not another (used on one, unused on other) without dead-ending, matching mypy/ty.

Normal unused comment that doesn't explicitly list `unused-ignore` is still reported.

Fixes facebook#3951
@github-actions

Copy link
Copy Markdown

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

1 participant