feat(python): recognize poetry run, filtering output like uv run#3003
Open
albatrossflyon-coder wants to merge 1 commit into
Open
feat(python): recognize poetry run, filtering output like uv run#3003albatrossflyon-coder wants to merge 1 commit into
albatrossflyon-coder wants to merge 1 commit into
Conversation
poetry run <tool> never reached the registry -- it's the single most frequent unhandled command in `rtk discover` output (408 calls/30d, ahead of every other unhandled entry), leaving ~96% noise unfiltered on a typical verbose pytest run through it. Added as a first-class command (`rtk poetry`, mirroring how `uv run` already works via `rtk uv`) rather than as a transparent-prefix strip: poetry run wraps an arbitrary tool the same way uv run does, so the same generic traceback/error-block filter applies regardless of which tool is being run underneath. poetry_cmd.rs mirrors uv_cmd.rs structurally for that reason -- same filtering approach, same passthrough-for-non-run behavior, same exit code propagation. Wiring: new RtkRule (`^poetry\s+run` -> `rtk poetry`, prefix `poetry`) so `rewrite_command` picks it up the same way it already does for uv; Commands::Poetry variant + dispatch; added to is_operational_command's whitelist (this gates hook-pipeline integrity verification -- a forgotten command here fails open, per that function's own doc comment, so it needs the same treatment as every other command in that list, not just to make rewrite work); added to PASSTHROUGH so the "every subcommand classified" consistency test passes. Fixes rtk-ai#2969
tapheret2
reviewed
Jul 15, 2026
tapheret2
left a comment
There was a problem hiding this comment.
Review: feat(python): recognize poetry run, filtering output like uv run
Files: src/cmds/python/poetry_cmd.rs, src/discover/rules.rs, src/main.rs
Size: +348 / -1
Notes
- Static pass on the patch: no obvious blockers from the diff alone.
Thanks @albatrossflyon-coder — independent review on the patch.
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
Fixes #2969.
poetry run <tool>never reached the registry — per the issue, it's the single most frequent unhandled command inrtk discoveroutput (408 calls in 30 days, ahead of everything else unhandled), leaving ~96% noise unfiltered on a typical verbose pytest run through it.Approach
Added
poetryas a first-class command (rtk poetry), mirroring exactly howuv runalready works viartk uv— not as a transparent-prefix strip.poetry runwraps an arbitrary tool the same wayuv rundoes, so the same generic traceback/error-block filter applies regardless of what's actually running underneath (pytest, ruff, black, whatever).poetry_cmd.rsmirrorsuv_cmd.rsstructurally for exactly that reason: same filtering logic, same passthrough behavior for non-runinvocations, same exit code propagation. This repo's existing convention is one file per tool (checked — no shared generic wrapper module exists yet forpip/uv/etc.), so this follows that rather than introducing a new pattern.Wiring (four places, in case any of it's useful context for review)
RtkRule(^poetry\s+run→rtk poetry, prefixpoetry) sorewrite_commandpicks it up the same way it already does foruv run.Commands::Poetryvariant + dispatch topoetry_cmd::run.is_operational_command's whitelist — this gates hook-pipeline integrity verification, and per that function's own doc comment a forgotten command here fails open (no check), so it needs the same treatment as every other command already in that list, not just enough to make the rewrite itself work.PASSTHROUGHin thetest_every_subcommand_is_classifiedconsistency check — caught this one by actually running the full suite before opening the PR, not just the commands I wrote.Verified live
(All exit 3 — "ask", the documented default for any rewritten command without an explicit permission rule, same as e.g.
git status. Not a bug — see the exit-code-protocol tests inrewrite_cmd.rs.)Full execution path against a real poetry project:
Testing
poetry_cmd.rs: success-noise suppression, traceback truncation, failure-summary-line preservation, failure fallbackcargo test: 2448 passed, 8 ignored, 0 failed (initially 1 failed — the whole-repotest_every_subcommand_is_classifiedconsistency check — fixed by point 4 above; leaving it in this summary since it's a good example of why running the full suite before opening matters)cargo clippy --all-targets -- -D warnings: clean