refactor: extract _version.py from __init__.py (PR-3/8)#2550
Open
darion-yaphet wants to merge 1 commit into
Open
refactor: extract _version.py from __init__.py (PR-3/8)#2550darion-yaphet wants to merge 1 commit into
darion-yaphet wants to merge 1 commit into
Conversation
Move version-checking helpers and `specify self` sub-commands into a focused `_version.py` module. Moved symbols: - GITHUB_API_LATEST — GitHub releases API endpoint constant - _get_installed_version — importlib.metadata-based version lookup - _normalize_tag — strip leading 'v' from release tag strings - _is_newer — PEP 440 version comparison - _fetch_latest_release_tag — single outbound call to GitHub API - self_app — Typer sub-app for `specify self` - self_check, self_upgrade — `specify self check/upgrade` commands Dependency rule: _version.py imports only stdlib + packaging + ._console. Backward compatibility: GITHUB_API_LATEST, self_check, self_upgrade remain importable from specify_cli via re-exports in __init__.py. Update test_upgrade.py to import helpers from specify_cli._version and patch at the correct module path (specify_cli._version.*). Add test_version_imports.py as regression guard.
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
Part 3 of 8 in the
__init__.pymodule split refactor.Extracts all version-checking logic and the
specify selfsub-command group from the 5361-line__init__.pyinto a focused_version.pymodule.Moved symbols:
GITHUB_API_LATEST— GitHub releases API endpoint constant_get_installed_version— importlib.metadata-based version lookup_normalize_tag— strip leadingvfrom release tag strings_is_newer— PEP 440 version comparison_fetch_latest_release_tag— single outbound call to GitHub API (5 s timeout)self_app— Typer sub-app forspecify selfself_check,self_upgrade—specify self check/upgradecommandsDependency rule:
_version.pyimports only stdlib +packaging+._console— no other internal modules at module level.Backward compatibility:
GITHUB_API_LATEST,self_check,self_upgraderemain importable fromspecify_clivia re-exports in__init__.py.Test plan
test_upgrade.pyimports tospecify_cli._versionand corrected patch paths tospecify_cli._version._get_installed_versiontests/test_version_imports.pyguards all re-exported symbolstest_upgrade.pyunrelated to this PR — same failures exist onmain)ruff check src/— all checks passed🤖 Generated with Claude Code