fix: skip update prompt when PyPI check fails (#480) - #486
Merged
Conversation
kaifcodec
approved these changes
Aug 1, 2026
kaifcodec
left a comment
Owner
There was a problem hiding this comment.
@A-S-Manoj LGTM.
Thank you for the tests.
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.
Fixes #480
Problem
get_pypi_version()catches any request failure (offline, PyPI down, rate limited, etc.) and returnsNoneinstead of raising.check_for_updates()compared this directly against the local version with noNonecheck, socurrent_ver != Nonewas always true on any failed check, producing a false prompt:[!] New version available: 1.4.1.9 -> None
Do you want to update? (y/n/d: don't ask again):
This isn't a rare edge case, it fires on any network failure. It also feeds into
update_self(), which uninstalls before reinstalling, so accepting the prompt while genuinely offline risks leaving the tool uninstalled.Fix
Added a check for
latest_ver is Noneimmediately after it's fetched, and return early with a clear message instead of comparing it againstcurrent_ver:"[!] Could not reach PyPI, skipping update check."and return, no prompt shownChanges
user_scanner/utils/updater_logic.py— added theNonecheck incheck_for_updates()before the version comparisontests/test_updater_logic.py(new) — regression coverage for the three cases aboveTesting
Ran the full test suite against current
main(151 passed). Verified the new tests fail on the unmodified code and pass with the fix:input()never calledinput()never calledWithout the fix, the unreachable case doesn't just show a false prompt, it goes on to crash with
'NoneType' object has no attribute 'strip'onceinput()is unexpectedly reached, since the mocked/aborted input path returnsNoneinstead of a string.No existing test covered this path. The closest one,
test_pypi_error_is_caughtin the incomingtest_updater_logic.pyPR, mocksget_pypi_versionto raise rather than returnNone, so it doesn't exercise this bug.