← Back to Pull requests

Fix `hatch.cli.application.Application.ensure_plugin_dependencies` PyApp Compatibility #2390

Closed
unknown closed this pull request without merging on Sep 20, 2026 22:55 UTC
View on GitHub
unknown unknown commented on Aug 13, 2026 23:29 UTC
Author

Fixes #2389.

What's the problem?

On the standalone PyApp binary, syncing environment plugin requirements was failing:

ERROR: The --python option must be placed before the pip subcommand name

hatch.cli.application.Application.ensure_plugin_dependencies builds <binary> <management-command> pip … in
the PyApp branch and uv pip … otherwise, but b1af6e83 (#1882) appended
uv-shaped arguments on a line shared by both branches:

pip_command.extend(["install", "--disable-pip-version-check", "--python", sys.executable])

--python is accepted by both tools, but in opposite positions:

| Invocation | Result |
| --- | --- |
| uv pip install --python X … | works |
| uv pip --python X install … | error: unexpected argument '--python' found |
| pip install --python X … | ERROR: The --python option must be placed before the pip subcommand name |
| pip --python X install … | works |

So no single argument order can serve both branches.

Why didn't the CI catch this issue previously?

hatch self pip … is not always uv. PyApp's pip_base_command() returns
uv pip only when PYAPP_UV_ENABLED is set, and otherwise
<managed python> -m pip. .github/workflows/build-hatch.yml:227 sets
PYAPP_UV_ENABLED=false for tagged release builds of the use-dist targets —
five of eight, including x86_64-unknown-linux-gnu, which is what the
pypa/hatch action installs on ubuntu-latest. Those binaries run real pip.

The test suite always took the non-PyApp branch, which really is uv, so the
broken path had no coverage at all.

How does this change _fix_ the problem?

Each branch now owns its own flags. The PyApp branch passes no --python — it
is redundant there regardless of which tool PyApp forwards to, since PyApp
already aims its installer at the managed interpreter via
UV_SYSTEM_PYTHON/VIRTUAL_ENV and PATH. The uv branch keeps --python
after install, and drops --disable-pip-version-check, which uv answers with
warning: pip's '--disable-pip-version-check' has no effect on every
invocation.

from uv import find_uv_bin also moves into the branch that uses it, matching
the lazy-import convention in the rest of the function.

How do we test this fix?

test_plugin_dependencies_unmet_pyapp covers the PyApp branch with unmet
requirements — the case that had no coverage, and the reason this regression
shipped. Supporting changes: assert_plugin_installation takes an
app_command argument, and mock_plugin_installation derives the command
prefix from PYAPP/PYAPP_COMMAND_NAME rather than assuming the management
command is named self, so the test honors the randomized name from the
isolation fixture.

AI assistance

I used Claude Code to diagnose the error, draft an initial (terrible) issue description, review my changes locally prior to opening this pull request, and to assemble a first draft of this pull request description.

Diff: 375 lines (+281 / -94) across 4 files Reviewer: cjames23 Review duration: 54685m
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 375 lines diff across 4 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.355
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2390"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 42.9% (MEDIUM) · Higher = larger blast radius
42.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 18.5% · Safe to merge
18.5%
Repository