Skip to content

PreToolUse pytest rewriter misses uv run pytest, poetry run pytest, python3 -m pytest #41

Description

@chirag127

Problem

_match_pytest in the PreToolUse rewriter only accepts pytest ... or python -m pytest ..., so modern invocations bypass the -q --tb=line rewrite. The paired PostToolUse compactor was widened for these forms in v4.3.0; the rewriter was not.

Steps

With TS_BASH_REWRITE=1, run any of:

  1. uv run pytest
  2. poetry run pytest
  3. hatch run pytest
  4. python3 -m pytest
  5. /path/to/venv/bin/python -m pytest

Expected

Command rewritten to append -q --tb=line (per v4.3.0 CHANGELOG claim: "Fixed pytest regex: now matches python3 -m pytest, uv run pytest, venv-prefixed forms, poetry/hatch/pdm/rye run pytest").

Actual

Rewriter returns unchanged; only bare pytest or literal python -m pytest match.

Cite

src/token_savior/bash_rewriter/rules.py:189-193 — early-return unless toks[0]=="pytest" or toks[:2]==["python","-m"]. Compare src/token_savior/compactors/pytest_.py _CMD_RE which accepts the wider set.

Environment

token-savior-recall 4.4.1 (pyproject.toml), Python 3.11+, main @ 1d822e9 (rules.py last touched 2026-05-19; compactor widened 2026-05-26 for v4.3.0).

Thanks for maintaining Mibayy/token-savior!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions