Skip to content

Add pants pyrefly-init onboarding goal#2

Merged
tague merged 1 commit into
mainfrom
tague/pyrefly-init
Jul 17, 2026
Merged

Add pants pyrefly-init onboarding goal#2
tague merged 1 commit into
mainfrom
tague/pyrefly-init

Conversation

@tague

@tague tague commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Part 2 of 3 for the 0.3.0 release.

Adds a pants pyrefly-init goal that bootstraps a Pyrefly config by wrapping pyrefly 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 written pyrefly.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-from is a passthrough StrOption (auto|mypy|pyright), not a bool — that's the actual CLI shape (default auto already tries mypy→pyright).
  • Dropped --force: pyrefly init refuses 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 with rm pyrefly.toml && pants pyrefly-init.
  • Always passes --non-interactive so the sandboxed run never blocks on a prompt. The post-init pyrefly check harmlessly 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) and test_init_refuses_existing_config (leaves an existing config byte-identical)

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>
@tague
tague merged commit 3cfc6d1 into main Jul 17, 2026
4 checks passed
@tague
tague deleted the tague/pyrefly-init branch July 17, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant