Skip to content

refactor(cli): simplify scaffold uipath pin to a guarded constant - #1874

Merged
andreibalas-uipath merged 1 commit into
mainfrom
fix/UV-16117-shared-dependency-spec-helper
Aug 28, 2026
Merged

refactor(cli): simplify scaffold uipath pin to a guarded constant#1874
andreibalas-uipath merged 1 commit into
mainfrom
fix/UV-16117-shared-dependency-spec-helper

Conversation

@andreibalas-uipath

@andreibalas-uipath andreibalas-uipath commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1869 (UV-16117). That PR made uipath new derive the scaffolded uipath>=X.Y.0, <X.(Y+1).0 pin 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.metadata would report. The two mechanisms only diverge when package metadata is missing — i.e. when uipath isn't installed, which is also when the uipath entry 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, the re import and the _get_safe_version lookup. The pin is formatted inline from a single documented constant, renamed UIPATH_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 between UIPATH_SCAFFOLD_MINOR and 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 new regression check for UV-16117 is unchanged.
  • Version bump 2.14.92.14.10.

Scaffold output is byte-for-byte unchanged ("uipath>=2.14.0, <2.15.0"). Everything else from #1869 (GUID id in uipath.json, hint whitespace fix, docs) is retained. Net vs main: +27 / −76.

Testing

  • pytest tests/cli/test_new.py — 8 passed; ruff check, ruff format --check, mypy clean.
  • Earlier iteration of this branch was verified end-to-end with a built 2.14.10 wheel in a fresh venv (uipath newuv sync with no downgrade → uipath inituipath run exit 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_MINOR constant, the pin formatted inline, and a guard test asserting the constant equals the installed minor. No shared helper is needed and no uipath floor bump is required.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings August 27, 2026 12:57
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-runtime test:uipath-integrations labels Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_spec helper to derive >=X.Y.0, <X.(Y+1).0 dependency pins from installed distribution metadata (with warning + fallback).
  • Updates uipath new to 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.

Comment thread packages/uipath/src/uipath/_cli/_utils/_dependency_spec.py Outdated
Comment thread packages/uipath/tests/cli/unit/test_dependency_spec.py Outdated
@andreibalas-uipath andreibalas-uipath self-assigned this Aug 27, 2026
@andreibalas-uipath
andreibalas-uipath force-pushed the fix/UV-16117-shared-dependency-spec-helper branch from 9c0f062 to b95bafe Compare August 28, 2026 09:48
@andreibalas-uipath andreibalas-uipath changed the title refactor(cli): extract reusable dependency-pin helper for scaffolds refactor(cli): simplify scaffold uipath pin to a guarded constant Aug 28, 2026
@andreibalas-uipath
andreibalas-uipath requested a lite review from Copilot August 28, 2026 09:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

Comment thread packages/uipath/src/uipath/_cli/cli_new.py
Comment thread packages/uipath/tests/cli/test_new.py Outdated
@andreibalas-uipath
andreibalas-uipath force-pushed the fix/UV-16117-shared-dependency-spec-helper branch from b95bafe to 4576ff0 Compare August 28, 2026 10:04
Comment thread packages/uipath/tests/cli/test_new.py Outdated
#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>
@andreibalas-uipath
andreibalas-uipath force-pushed the fix/UV-16117-shared-dependency-spec-helper branch from 4576ff0 to d0abee0 Compare August 28, 2026 10:55
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🚨 Heads up: uipath-langchain cross-tests are FAILING 🚨

Your changes may break the uipath-langchain-python integration.

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

@andreibalas-uipath
andreibalas-uipath merged commit 8d77eea into main Aug 28, 2026
230 of 231 checks passed
@andreibalas-uipath
andreibalas-uipath deleted the fix/UV-16117-shared-dependency-spec-helper branch August 28, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants