Automate Pyrefly version pins with a generator + CI drift check#3
Merged
Conversation
The four `default_known_versions` pins in subsystems.py (`<version>|<platform>|<sha256>|<size>`) were hand-computed on every Pyrefly bump. Add `build-support/bin/generate_known_versions.py` (stdlib only) that reads the version, URL template, and platform mapping straight out of subsystems.py via `ast` — so the script and the plugin can never disagree — then fetches each asset's published `.sha256` sidecar and size from the facebook/pyrefly GitHub release (falling back to downloading + hashing the asset). Modes: print the pins, `--version` to target a release, `--write` to splice the new version + pins back into subsystems.py (preserving formatting), and `--check` to fail if the committed pins drift from the release. CI runs `--check`. Adds `/build-support/bin` as a source root (keeps it linted/checked/tested; outside the `pants_pyrefly` package, so it never enters the wheel), a pure-logic unit test (no network), a README maintenance section, and a 0.3.0 changelog entry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Part 3 of 3 for the 0.3.0 release.
The four
default_known_versionspins insubsystems.py(<version>|<platform>|<sha256>|<size>) were hand-computed on every Pyrefly bump. This addsbuild-support/bin/generate_known_versions.py(stdlib only) that:subsystems.pyviaast, so the script and the plugin can never disagree;.sha256sidecar and size from the facebook/pyrefly GitHub release (falling back to downloading + hashing the asset).Modes: print the pins,
--versionto target a release,--writeto splice the new version + pins back intosubsystems.py(preserving formatting), and--checkto fail if the committed pins drift. CI runs--check.Adds
/build-support/binas a source root (keeps it linted/checked/tested; outside thepants_pyreflypackage, so it never enters the wheel), plus a pure-logic unit test (no network).Verification
pants fmt lint check test build-support/bin::✓ — ruff, Pyrefly-on-the-script (0 errors), unit testspants lint check ::✓ repo-wide--checkagainst the real GitHub release ✓ ("pins are current for 1.1.1")--writeroundtrip reproducessubsystems.pybyte-identically