Skip to content

fix: query installed_version("google-colab-cli") after PyPI rename#21

Open
teeler wants to merge 1 commit into
googlecolab:mainfrom
teeler:fix-version-after-rename
Open

fix: query installed_version("google-colab-cli") after PyPI rename#21
teeler wants to merge 1 commit into
googlecolab:mainfrom
teeler:fix-version-after-rename

Conversation

@teeler
Copy link
Copy Markdown
Contributor

@teeler teeler commented May 22, 2026

Summary

  • One-line fix: get_app_version() in src/colab_cli/auto_update.py was still calling importlib.metadata.version("colab") after the rename in change name of project #20 — repoint it to "google-colab-cli".
  • Strengthen test_version_installed with mock_version.assert_called_with("google-colab-cli") so a future rename can't silently regress this again.

Why

Verified live: after pip install google-colab-cli from PyPI (0.5.4), colab version printed Version: unknown instead of 0.5.4. Root cause: the rename missed this one call site. The lookup raised PackageNotFoundError, the function fell through to the git-rev-parse fallback, and inside an install venv (no git repo) that also fails and returns "unknown". The same broken value also flows into the auto-update banner's "current vs latest" comparison, which would mis-trigger.

The existing tests/test_version.py tests mock installed_version directly without asserting the argument, which is why CI passed for #20 despite the regression — the new assert_called_with closes that gap.

Verification

  • uv run pytest tests/ — 198 passed
  • uv run ruff check . — clean
  • Built a wheel from the fix branch, installed into a fresh venv, ran colab version: now prints the package version instead of "unknown". (Dev-suffixed locally because the build was pre-tag; on a tagged build the output is clean.)

The rename in googlecolab#20 (colab -> google-colab-cli) missed
get_app_version() in src/colab_cli/auto_update.py, which still asked
importlib.metadata for the old distribution name. After install from
the renamed PyPI package, the lookup raised PackageNotFoundError and
the function silently fell through to the git-rev-parse fallback;
inside an install venv with no git repo that also fails and the user
saw "Version: unknown" from `colab version` (and the same broken
value flowed into the auto-update banner's "current vs latest"
comparison).

Existing test_version.py tests mocked installed_version directly so
they didn't catch the wrong argument. Strengthen test_version_installed
with mock_version.assert_called_with("google-colab-cli") so a future
rename can't silently regress this again.

Verified by building a wheel and installing into a fresh venv:
`colab version` now prints the package version instead of "unknown".
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.

1 participant