From ffe205cb3e4c8729a39439bd5bf6981c60ecde9f Mon Sep 17 00:00:00 2001 From: Tyler Pirtle Date: Fri, 22 May 2026 23:56:47 +0000 Subject: [PATCH] fix: query installed_version("google-colab-cli") after PyPI rename The rename in #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". --- src/colab_cli/auto_update.py | 2 +- tests/test_version.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/colab_cli/auto_update.py b/src/colab_cli/auto_update.py index e9aab3c..5158d42 100644 --- a/src/colab_cli/auto_update.py +++ b/src/colab_cli/auto_update.py @@ -42,7 +42,7 @@ def get_app_version() -> str: """Return the installed package version, falling back to the git short hash.""" try: - return installed_version("colab") + return installed_version("google-colab-cli") except (PackageNotFoundError, InvalidVersion): pass diff --git a/tests/test_version.py b/tests/test_version.py index 6d41b28..7ee0776 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -27,6 +27,10 @@ def test_version_installed(): result = runner.invoke(app, ["version"]) assert result.exit_code == 0 assert "Version: 0.2.0" in result.output + # Guard against a silent regression if the PyPI distribution name + # changes again: importlib.metadata.version() must be called with + # the distribution name exactly as it appears in pyproject.toml. + mock_version.assert_called_with("google-colab-cli") def test_version_git_fallback():