This repository was archived by the owner on Jun 17, 2026. It is now read-only.
Format generated Python reliably; lint with UP rules - #86
Merged
Merged
Conversation
The post-generation Ruff step shelled out to a bare `ruff` on PATH. When the CLI is installed as an isolated tool (uv tool install / pipx), only the `pipecat`/`pc` scripts are exposed on PATH — Ruff's console script is not — so formatting was silently skipped (FileNotFoundError → pass), shipping raw, mis-indented template output. - Resolve the Ruff binary bundled with the CLI's dependencies via `ruff.__main__.find_ruff_bin()` (falling back to `python -m ruff`) instead of relying on PATH. - Surface a warning when Ruff cannot run or exits non-zero, rather than silently shipping unformatted code. - Enable Ruff's `UP` (pyupgrade) rules in generated projects alongside `I`. - Add regression tests: assert every generated config is Ruff-clean, that formatting works with `ruff` absent from PATH, and that failures warn.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
pipecat initis supposed to Ruff-format generated Python (ProjectGenerator._format_python_files), but the output often arrives raw — mis-indented blocks, stray blank lines, unsorted imports.Root cause: the formatting step shelled out to a bare
ruffonPATH.ruffis a hard runtime dependency, so it's installed alongside the CLI — but when the CLI is installed as an isolated tool (uv tool install/pipx), only the declaredpipecat/pcscripts are exposed onPATH. Ruff's console script lives in the tool's private venv and isn't reachable, sosubprocess.run(["ruff", ...])raisedFileNotFoundError, which was caught andpassed — formatting silently skipped. (It worked in a dev checkout because.venv/binis onPATH, which is why it wasn't caught.)Changes
ruff.__main__.find_ruff_bin(), falling back to[sys.executable, "-m", "ruff"]— no longer depends onruffbeing onPATH.UP(pyupgrade) lint rules in generated projects'pyproject.tomlalongside import sorting (I).Tests
Added regression guards in
tests/test_project_generation.py:server/is Ruff-clean (ruff format --check).test_generated_python_formatted_without_ruff_on_path— pointsPATHat an empty dir (verifiesruffis genuinely unreachable) and confirms output is still formatted. Guards the bundled-binary resolution.test_format_warns_when_ruff_cannot_run— confirms a warning is emitted when Ruff can't run.Verified these tests go red against the old bare-
ruffbehavior and green with the fix.Verification
Full real-world reproduction before/after: built the wheel,
uv tool install'd it into throwaway dirs, ranpc initin a shell withruffabsent fromPATH→ exit 0, no warning, fully formattedbot.py,ruff format --checkreports clean.Suite: 418 passed (was 416).
🤖 Generated with Claude Code