Fix `hatch.cli.application.Application.ensure_plugin_dependencies` PyApp Compatibility #2390
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
cjames23
Fixes #2389.
What's the problem?
On the standalone PyApp binary, syncing environment plugin requirements was failing:
hatch.cli.application.Application.ensure_plugin_dependenciesbuilds<binary> <management-command> pip …inthe PyApp branch and
uv pip …otherwise, but b1af6e83 (#1882) appendeduv-shaped arguments on a line shared by both branches:
--pythonis 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'spip_base_command()returnsuv piponly whenPYAPP_UV_ENABLEDis set, and otherwise<managed python> -m pip..github/workflows/build-hatch.yml:227setsPYAPP_UV_ENABLED=falsefor tagged release builds of theuse-disttargets —five of eight, including
x86_64-unknown-linux-gnu, which is what thepypa/hatchaction installs onubuntu-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— itis redundant there regardless of which tool PyApp forwards to, since PyApp
already aims its installer at the managed interpreter via
UV_SYSTEM_PYTHON/VIRTUAL_ENVandPATH. The uv branch keeps--pythonafter
install, and drops--disable-pip-version-check, which uv answers withwarning: pip's '--disable-pip-version-check' has no effecton everyinvocation.
from uv import find_uv_binalso moves into the branch that uses it, matchingthe lazy-import convention in the rest of the function.
How do we test this fix?
test_plugin_dependencies_unmet_pyappcovers the PyApp branch with unmetrequirements — the case that had no coverage, and the reason this regression
shipped. Supporting changes:
assert_plugin_installationtakes anapp_commandargument, andmock_plugin_installationderives the commandprefix from
PYAPP/PYAPP_COMMAND_NAMErather than assuming the managementcommand is named
self, so the test honors the randomized name from theisolationfixture.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.