Let # pyrefly: ignore exclude symbols from pyrefly coverage#3919
Let # pyrefly: ignore exclude symbols from pyrefly coverage#3919jorenham wants to merge 1 commit into
# pyrefly: ignore exclude symbols from pyrefly coverage#3919Conversation
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
NathanTempest
left a comment
There was a problem hiding this comment.
Thanks for the well-thought-out feature, @jorenham and for the real test of the design choice (zeroing slots so excluded symbols drop out of the percentage, not just the output).
Plain pyrefly check no longer treating coverage-* codes as unused , a small but real correctness fix; nice that you covered the mixed-code case (bad-override still flagged, coverage-missing silently ignored).
The refactor in state/errors.rs (extracting Error::unused_ignore + Error::unused_pyrefly_ignore) is a net win ~50 lines of repeated range-building boilerplate gone. And confirmed the new exclusion pass is safe under the parallel collect_one from #3825 since each closure owns its ModuleSymbols. LGTM and importing. Thanks for another contribution to Pyrefly!
|
@NathanTempest has imported this pull request. If you are a Meta employee, you can view this in D109597080. |
Summary
The
pyrefly coveragecommands now respects# pyrefly: ignore. Because, well, they didn't before... An ignored symbol was still reported and still counted against the percentage. If unused ignores were configured, thenpyrefly checkwould also complain about them.Now, we can do things like
which will cause
legacyto not be reported as a warning anymore bycoverage check, and will no longer affect the total coverage percentages ofcoverage checkandcoverage report(counted as 0 typables).Specifically ignoring
[coverage-partial]and a bare# pyrefly: ignorework too.However, I chose to not include
# type: ignore, even if explicitly configured. That's because those have always been intended for type errors, and also because Pyrefly is the only type-coverage checker out there, so it's probably safe to assume that a# type: ignorewasn't intended to ignore coverage.A coverage ignore that matches nothing is flagged as unused by
coverage check, and plainpyrefly checkno longer reportscoverage-*codes as unused (they're only forcoverage check).For decorated symbols like a
@property, the# pyrefly: ignoreshould be placed on the decorator line (that's where the coverage diagnostic starts).Test Plan
Added tests for exclusion (incl. properties), unused/out-of-scope ignores, the
type: ignoreboundary, andcheck/reportconsistency.