Skip to content

Support typed ignore-errors directives - #3944

Closed
WilliamK112 wants to merge 1 commit into
meta:mainfrom
WilliamK112:codex/pyrefly-ignore-errors-codes
Closed

WilliamK112 wants to merge 1 commit into
meta:mainfrom
WilliamK112:codex/pyrefly-ignore-errors-codes

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • Support # pyrefly: ignore-errors[code] as a file-level suppression for selected Pyrefly error codes.
  • Reuse the existing Suppression representation for file-level directives so whole-file and line-level Pyrefly code matching share the same semantics, including parent suppression names.
  • Keep non-Pyrefly ignore-errors directives as blanket-only and document the new Pyrefly form.

Fixes #3723

Notes

This is scoped to file-level code filtering for pyrefly: ignore-errors. Related suppression lint/reporting PRs (#3832 and #3797) address separate diagnostics and unused-ignore behavior.

Validation

  • cargo fmt --check
  • git diff --check
  • cargo test -p pyrefly_python test_parse_ignore_all
  • CARGO_TARGET_DIR=/Users/William/pyrefly-target-codex cargo test -p pyrefly test_pyrefly_top_level_ignore_typed

Signed-off-by: WilliamK112 <164879897+WilliamK112@users.noreply.github.com>
@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. ✅

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

Thanks @WilliamK112, welcome, and nice work. Reusing Suppression so file-level ignore-errors[code] shares the exact same representation and bracket-parsing as line-level ignore[code] is the right call, and keeping ignore-errors[code] Pyrefly-only (blanket for mypy/pyre) matches those tools' real semantics. LGTM for importing.

One possible follow-up: parse_ignore_all_kind duplicates the split(',')/trim bracket parse from parse_ignore_comment could share a helper someday. I will address this after importing this PR, nothing for you to do and thank you for the fix

@meta-codesync

meta-codesync Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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

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

Review automatically exported from Phabricator review in Meta.

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

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in 6f9791b Jul 8, 2026
@meta-codesync meta-codesync Bot added the Merged label Jul 8, 2026
@meta-codesync

meta-codesync Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@NathanTempest merged this pull request in 6f9791b.

avokin2 pushed a commit to avokin2/pyrefly that referenced this pull request Aug 12, 2026
Summary:
- Support `# pyrefly: ignore-errors[code]` as a file-level suppression for selected Pyrefly error codes.
- Reuse the existing `Suppression` representation for file-level directives so whole-file and line-level Pyrefly code matching share the same semantics, including parent suppression names.
- Keep non-Pyrefly `ignore-errors` directives as blanket-only and document the new Pyrefly form.

Fixes meta#3723

Import note (maintainer changes on top of the PR, addressing Devmate review nits):
- Dedupe the `[code, code]` parse into a shared `parse_error_codes` helper used by both the line-level and file-level parsers.
- Reject malformed file-level directives with a missing closing `]` (previously silently accepted as valid).
- Drop empty entries so `# pyrefly: ignore-errors[]` (and trailing commas) act as a blanket ignore rather than a directive matching nothing.
- Update the `parse_ignore_all` docstring to reflect its `Vec<Suppression>` return shape.

## Notes
This is scoped to file-level code filtering for `pyrefly: ignore-errors`. Related suppression lint/reporting PRs (meta#3832 and meta#3797) address separate diagnostics and unused-ignore behavior.

Pull Request resolved: meta#3944

Test Plan: buck test pyrefly:pyrefly_library -- test_pyrefly_top_level_ignore (6 pass); buck test pyrefly_python -- test_parse_ignore (4 pass, incl. empty-bracket + missing-bracket cases).

Reviewed By: kinto0

Differential Revision: D110063592

Pulled By: NathanTempest

fbshipit-source-id: 734d71d546e8d39f696b31af3eaeb0a53d6f094f
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.

Support whole file suppression for specific error codes (pyrefly: ignore-errors)

3 participants