Repository navigation
feat: add opt-in ignore-without-code lint - #5751
Closed
Aayushyaash wants to merge 2 commits into
Closed
Aayushyaash wants to merge 2 commits into
Aayushyaash wants to merge 2 commits into
Conversation
Co-authored-by: Mikko Leppänen <[email protected]>
|
✅ This PR meets all requirements from our pull request checklist. Optional recommendations:
Note: this comment updates automatically after changes to the PR. Updates may take up to half an hour. |
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D134246495. (Because this pull request was imported automatically, there will not be any future comments.) |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Mikko Leppänen <[email protected]>
Aayushyaash
force-pushed
the
fix-ignore-without-code
branch
from
November 24, 2026 14:56
5ac007d to
06c724f
Compare
|
Diff from mypy_primer, showing the effect of this PR on open source code: ============================================================
SUMMARY
============================================================
Total: +5 new errors, -0 fixed errors
By preset: +0/-0 (default), +0/-0 (strict)
Projects with changes (2):
numpy-stl: +3 -0
ignite: +2 -0
============================================================
FULL DIFF DETAILS
------------------------------------------------------------
numpy-stl (https://github.com/WoLpH/numpy-stl)
+ ERROR stl/base.py:503:76-93: `# pyrefly: ignore` has no error code; specify the code(s) being suppressed, e.g. `# pyrefly: ignore[bad-return]` [ignore-without-code]
+ ERROR stl/base.py:557:71-88: `# pyrefly: ignore` has no error code; specify the code(s) being suppressed, e.g. `# pyrefly: ignore[bad-return]` [ignore-without-code]
+ ERROR stl/base.py:559:58-75: `# pyrefly: ignore` has no error code; specify the code(s) being suppressed, e.g. `# pyrefly: ignore[bad-return]` [ignore-without-code]
ignite (https://github.com/pytorch/ignite)
+ ERROR ignite/handlers/lr_finder.py:321:30-47: `# pyrefly: ignore` has no error code; specify the code(s) being suppressed, e.g. `# pyrefly: ignore[bad-return]` [ignore-without-code]
+ ERROR ignite/handlers/visdom_logger.py:179:28-45: `# pyrefly: ignore` has no error code; specify the code(s) being suppressed, e.g. `# pyrefly: ignore[bad-return]` [ignore-without-code] |
stroxler
approved these changes
Nov 24, 2026
stroxler
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Contributor
|
This pull request has been merged in 0e1f12d. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A bare
# pyrefly: ignorecomment suppresses all errors on its line. In growing codebases, this can silently hide unrelated errors introduced during future refactoring.This PR introduces the
ignore-without-codelint rule (default severity:ignore, opt-in, enabled in theallpreset). It provides a Pyrefly equivalent of basedpyright'sreportIgnoreCommentWithoutRuleand mypy'signore-without-code.When enabled, every
# pyrefly: ignoredirective must explicitly specify the error code(s) it suppresses.This PR completes the second part of closed PR #3832 by @mikeleppane, splitting it into an independent PR as requested by maintainers following the merge of PR #5583.
Closes #3450
Test Plan
Unit tests in
pyrefly/lib/state/errors.rs:test_ignore_without_code_disabled_by_default: Verifies the rule is disabled by default.test_ignore_without_code_emitted: Verifies bare# pyrefly: ignoreis flagged while coded directives like# pyrefly: ignore[bad-assignment]are not.test_ignore_without_code_scoped_to_pyrefly: Verifies bare# type: ignore,# pyright: ignore, and# pyre: ignoreare not flagged.test_ignore_without_code_survives_file_level_ignore_errors: Verifies file-level# pyrefly: ignore-errorscannot suppress this lint.End-to-end Scrut tests in
test/ignores.md:[0]).errors = {ignore-without-code = true}([1]).Preset and documentation tests:
test_error_presets_jsonpasses (registered only in theallpreset).test_doc_headerspasses.website/docs/error-kinds.mdxandwebsite/docs/migrate/mypy/error-codes.mdx.Validation