Add pants pyrefly-init onboarding goal#2
Merged
Merged
Conversation
Wraps `pyrefly init` to bootstrap a Pyrefly config for the repo, migrating an existing MyPy or Pyright configuration when one is found. Runs the subcommand in a config-only sandbox (no sources — init does not type-check), captures the written pyrefly.toml / pyproject.toml, and writes back only the files it changed. `--pyrefly-init-migrate-from=<auto|mypy|pyright>` selects the migration source (passthrough to `--migrate-from`). Always passes `--non-interactive` so the sandboxed run never blocks on a prompt. Refuses to overwrite an existing config (pyrefly.toml or a pyproject.toml [tool.pyrefly] table) with a clear message, mirroring `pyrefly init`'s own behavior. Includes integration tests for the migrate and refuse paths, a README "Getting started" section, a migrating-from-mypy doc update to use the goal, 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 2 of 3 for the 0.3.0 release.
Adds a
pants pyrefly-initgoal that bootstraps a Pyrefly config by wrappingpyrefly init, migrating an existing MyPy or Pyright configuration when one is found. Lowers the barrier to adopting Pyrefly on an existing repo.Runs
pyrefly init --non-interactive [--migrate-from X] .in a config-only sandbox (no sources — init does not type-check), captures the writtenpyrefly.toml/pyproject.toml, and writes back only the files it changed.Deviations from the original plan (driven by testing the real CLI)
--pyrefly-init-migrate-fromis a passthroughStrOption(auto|mypy|pyright), not a bool — that's the actual CLI shape (defaultautoalready tries mypy→pyright).--force:pyrefly initrefuses to overwrite an existing config (exit 1) and has no force flag, so the goal detects an existing config and refuses with a clear message. Regenerate withrm pyrefly.toml && pants pyrefly-init.--non-interactiveso the sandboxed run never blocks on a prompt. The post-initpyrefly checkharmlessly reports "no Python files" (exit 0) in the config-only sandbox and is ignored.Verification
pants lint check✓ (0 errors)pants test ::✓ —test_init_creates_config(real mypy→pyrefly migration) andtest_init_refuses_existing_config(leaves an existing config byte-identical)