fix: query installed_version("google-colab-cli") after PyPI rename#21
Open
teeler wants to merge 1 commit into
Open
fix: query installed_version("google-colab-cli") after PyPI rename#21teeler wants to merge 1 commit into
teeler wants to merge 1 commit into
Conversation
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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_app_version()insrc/colab_cli/auto_update.pywas still callingimportlib.metadata.version("colab")after the rename in change name of project #20 — repoint it to"google-colab-cli".test_version_installedwithmock_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-clifrom PyPI (0.5.4),colab versionprintedVersion: unknowninstead of0.5.4. Root cause: the rename missed this one call site. The lookup raisedPackageNotFoundError, 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.pytests mockinstalled_versiondirectly without asserting the argument, which is why CI passed for #20 despite the regression — the newassert_called_withcloses that gap.Verification
uv run pytest tests/— 198 passeduv run ruff check .— cleancolab 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.)