Skip to content

fix(cli): only show update notice when PyPI version is actually newer#993

Open
berettavexee wants to merge 1 commit into
nathom:devfrom
berettavexee:fix/cli-version-check
Open

fix(cli): only show update notice when PyPI version is actually newer#993
berettavexee wants to merge 1 commit into
nathom:devfrom
berettavexee:fix/cli-version-check

Conversation

@berettavexee

@berettavexee berettavexee commented Jun 14, 2026

Copy link
Copy Markdown

Problem

The update check compares versions with !=:

if latest_version != __version__:
    console.print("A new version is available!")

This means the notice also fires when the installed version is newer than PyPI — e.g. on a dev install, a pre-release, or a fork. Users on dev installs see the "please upgrade" message on every run even though they're already ahead of the release.

Fix

Compare version tuples numerically so the notice only appears when PyPI actually has a newer release:

def _ver(v):
    try:
        return tuple(map(int, v.split(".")))
    except (ValueError, AttributeError):
        return (0, 0, 0)
if _ver(latest_version) > _ver(__version__):

The helper also handles malformed version strings gracefully (returns (0, 0, 0), suppressing the notice).

Test plan

  • Installed version == PyPI version → no notice
  • Installed version < PyPI version → notice shown
  • Installed version > PyPI version (dev/fork) → no notice
  • Malformed version string from PyPI → no notice, no exception

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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