refactor(cli): simplify scaffold uipath pin to a guarded constant - #1874
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the uipath new scaffold dependency pinning logic into a reusable CLI utility so downstream/plugin CLIs can import the same “derive installed minor-range pin with fallback” behavior without duplicating code.
Changes:
- Introduces a shared
_dependency_spechelper to derive>=X.Y.0, <X.(Y+1).0dependency pins from installed distribution metadata (with warning + fallback). - Updates
uipath newto use the shared helper and adjusts existing scaffold pin tests accordingly. - Adds focused unit tests for the new helper and bumps the package version to
2.14.10.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/uipath/src/uipath/_cli/_utils/_dependency_spec.py | New shared helper for deriving/falling back dependency spec pins. |
| packages/uipath/src/uipath/_cli/cli_new.py | Uses derive_dependency_spec() when writing scaffolded pyproject.toml. |
| packages/uipath/tests/cli/test_new.py | Updates scaffold pin tests to patch the new helper and reuse fallback_dependency_spec(). |
| packages/uipath/tests/cli/unit/test_dependency_spec.py | Adds unit tests directly covering the helper API and edge cases. |
| packages/uipath/pyproject.toml | Version bump to 2.14.10. |
| packages/uipath/uv.lock | Lockfile updated for the new version. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
9c0f062 to
b95bafe
Compare
b95bafe to
4576ff0
Compare
#1869 made `uipath new` derive its `uipath>=X.Y.0, <X.(Y+1).0` pin from the installed distribution, with a constant fallback and a CI guard that fails when the fallback lags the release. With that guard in place the runtime detection is redundant: for every shipped wheel the constant already equals the installed minor. Drop the detection and keep the constant, renamed UIPATH_SCAFFOLD_MINOR. The guard test now checks strict equality with the installed minor so a minor bump fails CI in both directions and prompts a review of the whole scaffold (pin, template, hints), not just a mechanical bump. Scaffold output is unchanged. Bump 2.14.9 -> 2.14.10. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4576ff0 to
d0abee0
Compare
|
🚨 Heads up:
|



Summary
Follow-up to #1869 (UV-16117). That PR made
uipath newderive the scaffoldeduipath>=X.Y.0, <X.(Y+1).0pin from the installed distribution at runtime, with a constant fallback (FALLBACK_UIPATH_MINOR) and a CI guard test that fails when the fallback lags the release.With the guard in place the runtime detection is redundant: the guard forces the constant to match the minor of every release that ships, so in any installed wheel the constant already equals what
importlib.metadatawould report. The two mechanisms only diverge when package metadata is missing — i.e. whenuipathisn't installed, which is also when theuipathentry point doesn't exist.This PR keeps the simpler of the two. A deliberate constant also has an advantage detection can't offer: a minor bump turns CI red, which is the natural moment to review whether the rest of the scaffold (template, hints) needs updating for the new release.
Changes
cli_new.py: remove_uipath_dependency_spec/_fallback_uipath_dependency_spec/_minor_range_spec, thereimport and the_get_safe_versionlookup. The pin is formatted inline from a single documented constant, renamedUIPATH_SCAFFOLD_MINOR(it is no longer a fallback).tests/cli/test_new.py: the three mocked-version tests go away with the code they tested. The guard now asserts strict equality betweenUIPATH_SCAFFOLD_MINORand the installed minor, so a constant that is ahead of the release fails too, and its failure message reads as a review prompt: "review the scaffold in cli_new.py (pin, template, hints) and bump the constant". The real-uipath newregression check for UV-16117 is unchanged.2.14.9→2.14.10.Scaffold output is byte-for-byte unchanged (
"uipath>=2.14.0, <2.15.0"). Everything else from #1869 (GUIDidinuipath.json, hint whitespace fix, docs) is retained. Net vsmain: +27 / −76.Testing
pytest tests/cli/test_new.py— 8 passed;ruff check,ruff format --check, mypy clean.uipath new→uv syncwith no downgrade →uipath init→uipath runexit 0); the scaffold output is identical in this iteration.Follow-up for plugin CLIs
UiPath/uipath-langchain-python#1052 (and later
uipath-llamaindex,uipath-openai-agents) should follow the same pattern: one*_SCAFFOLD_MINORconstant, the pin formatted inline, and a guard test asserting the constant equals the installed minor. No shared helper is needed and nouipathfloor bump is required.🤖 Generated with Claude Code