Skip to content

feat(suppress): support removal of # type: ignore suppressions with pyrefly suppress --remove-unused#4200

Open
tobyh-canva wants to merge 5 commits into
facebook:mainfrom
tobyh-canva:feat/suppress-remove-unused-type-ignores
Open

feat(suppress): support removal of # type: ignore suppressions with pyrefly suppress --remove-unused#4200
tobyh-canva wants to merge 5 commits into
facebook:mainfrom
tobyh-canva:feat/suppress-remove-unused-type-ignores

Conversation

@tobyh-canva

@tobyh-canva tobyh-canva commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Changes pyrefly suppress --remove-unused and pyrefly check --remove-unused-ignores so that users can specify --remove-unused=type / --remove-unused=all to instead / additionally remove # type: ignore comments, rather than just # pyrefly: ignore comments.

The default remains unchanged, so as to not surprise users previously relying on pyrefly suppress --remove-unused suddenly removing load-bearing # type: ignore comments.

Resolves #3984.

Comment thread pyrefly/lib/error/suppress.rs
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/l and removed size/l labels Jul 18, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/l and removed size/l labels Jul 18, 2026
@tobyh-canva
tobyh-canva marked this pull request as ready for review July 18, 2026 08:45
@github-actions

This comment has been minimized.

@kinto0 kinto0 self-assigned this Jul 21, 2026
@meta-codesync

meta-codesync Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

@kinto0 kinto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would love @maggiemoss 's perspective on this

Comment thread pyrefly/lib/commands/check.rs Outdated
Comment thread pyrefly/lib/commands/check.rs Outdated
Comment thread pyrefly/lib/error/suppress.rs
@kinto0
kinto0 requested a review from maggiemoss July 21, 2026 23:09
Comment thread pyrefly/lib/error/suppress.rs Outdated
@github-actions github-actions Bot added size/l and removed size/l labels Jul 22, 2026
@github-actions

This comment has been minimized.

@maggiemoss

Copy link
Copy Markdown
Contributor

What if instead of new flags for each kind of ignore, we had the ability to pass an option to it and specify which kind?

Comment thread pyrefly/lib/commands/check.rs Outdated
Comment thread pyrefly/lib/commands/check.rs Outdated
@github-actions github-actions Bot added size/xl and removed size/l labels Jul 23, 2026
@tobyh-canva

Copy link
Copy Markdown
Collaborator Author

Here's what the flag's help looks like from pyrefly suppress --help after addressing feedback:

--remove-unused[=<KIND>]
    Remove unused ignores instead of adding suppressions, optionally selecting `pyrefly`,
    `type`, or `all`. Defaults to `pyrefly` when no kind is specified

    Possible values:
    - pyrefly: Remove unused Pyrefly and Pyre ignores (default)
    - type:    Remove unused `# type: ignore` comments
    - all:     Remove unused Pyrefly, Pyre, and `# type: ignore` comments

@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. ✅

@tobyh-canva tobyh-canva changed the title feat(suppress): add --remove-unused-type-ignores flag feat(suppress): support removal of # type: ignore suppressions with pyrefly suppress --remove-unused Jul 23, 2026
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: --remove-unused-type-ignores flag to clean up unused # type: ignore comments

3 participants