Skip to content

microskills: the Windows py launcher is not read as the Python interpreter #340

Backlog

Description

classify_command in tokeneconomizer/microskills/observe.py reads python.exe and C:\Python312\python.exe as the Python interpreter, but not the Windows py launcher. CPython's "Using Python on Windows" says "To launch your default runtime, run python or py", and a -V:<tag> or -3.x option chooses a specific Python. So py -m pytest is not observed, and a repository whose tests run that way never gets a fact about them.

Reproduction (offline):

from tokeneconomizer.microskills.observe import classify_command

for cmd in ["python.exe -m pytest", "py -m pytest", "py -3.12 -m pytest"]:
    print(cmd, "->", [(o.intent, o.form) for o in classify_command(cmd)])

Expected: run_tests for all three, py's version option kept in the form
Actual: [('run_tests', 'python.exe -m pytest')] for the first, [] for both py forms

Upstream main: 747b801
Python 3.13.18, Linux

Activity

  1. github-actions commented on Nov 26, 2026

    @github-actions

    Scout plan

    Issue: #340 — microskills: the Windows py launcher is not read as the Python interpreter

    Understanding

    classify_command (tokeneconomizer/microskills/observe.py) only treats python, python2/3, pypy* (PYTHON_GIT.interpreters, line 51) and pythonN[.M] (_INTERP_VERSIONED_RE, line 164) as interpreters. py -m pytest therefore yields no observation. The end state is that py, with or without a version selector (-3, -3.12, -V:3.12), is read as the Python interpreter and records run_tests, with the selector kept in the form. The issue doesn't say whether py.exe should work, but _command_base (line 839) already strips .exe, so it follows.

    Approach

    1. In observe.py, add "py" to PYTHON_GIT.interpreters. GENERIC (line 74) is the union of the two vocabularies, so it picks py up with no further change.

    2. Add a small helper in observe.py and a module regex, e.g. _PY_SELECTOR_RE, matching ^-(?:V:\S+|\d(?:\.\d+)?(?:-(?:32|64|arm64))?)$. In _classify, when base == "py", split a leading selector token from rest. The remaining arguments then drive the existing logic: the --version/-V/-VV/-v probe check, -m, and _runner_script. This matters because py -3.12 --version would otherwise fail the all-tokens check, and py -3.12 script.py would not be recognised as a runner script.

    3. Build the form from head plus the selector (py -3.12 -m pytest, py -V:3.12 -m pytest), so the selector is kept as the issue asks. Do this for the run_tests, run_interpreter, probe_env and coverage run branches. Without a selector the form is unchanged (py -m pytest).

    4. py -0 and py -0p list installed runtimes. Make them probe_env rather than run_interpreter; check that -0 isn't swallowed as a selector.

    5. Add tests/test_observe_py_launcher.py in the style of tests/test_observe_conda_run.py. It should cover:

      • the three commands from the issue, with expected forms python.exe -m pytest, py -m pytest and py -3.12 -m pytest;
      • py -V:3.12 -m pytest, py.exe -3 -m pytest and C:\Windows\py.exe -m pytest;
      • py -3.12 -m coverage run -m pytest;
      • py -3.12 runtests.py;
      • py --version and py -0 as probe_env;
      • a negative case such as py -m pip install x not being run_tests.

    No on-disk state names, event kinds or settings change. Observation forms are keyed by their text, so new py ... forms simply pool separately from python ... ones. The plugin's user-visible text is untouched.

    Verification

    • python -m pytest tests/test_observe_py_launcher.py -q
    • python -m pytest tests experiments/tests -q
    • Run the issue's reproduction snippet and confirm run_tests for all three commands.
    • Replay any recorded Windows sessions that use py through the observation step, if available. The change adds observations and shouldn't alter any existing python form.

    Open questions

    None


    Reply confirm to have scout implement this plan on a scout/issue-340 branch and link a one-click pull request (write access required). Reply /scout to plan again after editing the issue; text after the command is guidance for the new plan.

    Generated by Scout for #340 · claude · sonnet55 · ~15 AIC · ⌖ ~16 AIC · ⊞ 2.6K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions