Skip to content

Harden Python SDK version resolution - #987

Closed
bmehta001 wants to merge 1 commit into
mainfrom
bhamehta/fix-version-review
Closed

Harden Python SDK version resolution#987
bmehta001 wants to merge 1 commit into
mainfrom
bhamehta/fix-version-review

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

Summary

Address Copilot review feedback for Python SDK version resolution.

Changes

  • Prefer the adjacent source checkout's pyproject.toml version before consulting installed distribution metadata, preventing an unrelated installed wheel from masking the local source version.
  • Add focused unit tests for source-tree precedence, installed metadata, missing pyproject.toml, malformed configuration, and unknown-version fallback.

Validation

  • python -m pytest sdk_v2/python/test/unit/test_version.py sdk_v2/python/test/unit/test_imports.py -q — 18 passed

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c57f1ea3-b538-4db9-9223-8ca4f174f277
Copilot AI balanced review requested due to automatic review settings August 12, 2026 06:04
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview Aug 12, 2026 6:04am

Request Review

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

Hardens Python SDK version resolution across source and installed environments.

Changes:

  • Prioritizes the source checkout’s pyproject.toml.
  • Falls back to installed metadata or an unknown version.
  • Adds focused version-resolution tests.

Reviewed changes

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

File Description
sdk_v2/python/src/foundry_local_sdk/version.py Implements layered version resolution.
sdk_v2/python/test/unit/test_version.py Tests precedence and fallback behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

def test_malformed_pyproject_falls_back_to_unknown(monkeypatch, tmp_path: Path):
pyproject = tmp_path / "pyproject.toml"
pyproject.write_text("[project\n", encoding="utf-8")
monkeypatch.setattr(version_module, "_version_from_source_tree", lambda: version_module._version_from_pyproject(pyproject))
Comment on lines +24 to +25
found = data.get("project", {}).get("version")
return found if isinstance(found, str) and found else None
@bmehta001 bmehta001 closed this Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants