Repository navigation
Add pyrefly as a second type checker - #1017
Open
jonathan343 wants to merge 1 commit into
Open
jonathan343 wants to merge 1 commit into
jonathan343 wants to merge 1 commit into
Conversation
Run pyrefly in check-py with a per-package config, and record existing errors in pyrefly-baseline.json so only new errors fail the check.
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
This adds pyrefly 1.5.2 as a second type checker, run by
make check-pyafter pyright. In an audit of pyright, mypy, ty and pyrefly on this repo, pyrefly reported real defects that pyright misses. Some implementations of theURIprotocol make its mutable attributes read-only.ShapeSerializer.flushhas only a docstring, so pyrefly treats it as abstract, and every serializer without its ownflushcan't be instantiated. Pyright stays, because pyrefly has nothing like--verifytypesor pyright's strict-mode checks for unknown types.The errors pyrefly reports today are recorded in
pyrefly-baseline.json, so the check fails only on new errors. Most of its 162 entries come from three root causes:flush(68), a test protocol in smithy-http that declaresIDandSCHEMAwithout values (51), and theURIandPropertyKeyoverrides (18). Follow-up PRs will fix those errors and pyrefly's 6 existing warnings, and consider stricter settings.Decisions
[tool.pyrefly]config. Every package has a top-leveltestspackage, so one config for the whole repo would see 11 modules namedtests. With a config in each package,pyrefly check packages/*/checks each package as a separate project withsearch-path = [".", "src"]. The configs honor the existing# pyright: ignorecomments, so pyrefly skips the lines pyright already ignores.column-orderedmatching. In the defaultcolumnmode, an entry matches on file, error kind and column, so one entry hides any number of errors. A second_BlobRecorder()in a file that already has baseline entries passed the check in that mode and fails in this one. Entries for errors that have since been fixed also fail the check (--error-stale-baseline).make pyrefly-baselineremoves them, and nomaketarget adds entries.Testing
Adding a new error to a file that already has baseline entries fails the check:
Fixing
flushfails the check because 68 entries are now stale.make pyrefly-baselinethen removes them and leaves 94.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.