Skip to content

refactor: extract _version.py from __init__.py (PR-3/8)#2550

Open
darion-yaphet wants to merge 1 commit into
github:mainfrom
darion-yaphet:refactor/split-init-pr3
Open

refactor: extract _version.py from __init__.py (PR-3/8)#2550
darion-yaphet wants to merge 1 commit into
github:mainfrom
darion-yaphet:refactor/split-init-pr3

Conversation

@darion-yaphet
Copy link
Copy Markdown
Contributor

Summary

Part 3 of 8 in the __init__.py module split refactor.

Extracts all version-checking logic and the specify self sub-command group from the 5361-line __init__.py 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 (5 s timeout)
  • self_app — Typer sub-app for specify self
  • self_check, self_upgradespecify self check/upgrade commands

Dependency rule: _version.py imports only stdlib + packaging + ._console — no other internal modules at module level.

Backward compatibility: GITHUB_API_LATEST, self_check, self_upgrade remain importable from specify_cli via re-exports in __init__.py.

Test plan

  • Updated test_upgrade.py imports to specify_cli._version and corrected patch paths to specify_cli._version._get_installed_version
  • New tests/test_version_imports.py guards all re-exported symbols
  • 40 tests pass (9 pre-existing failures in test_upgrade.py unrelated to this PR — same failures exist on main)
  • ruff check src/ — all checks passed

🤖 Generated with Claude Code

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.
@darion-yaphet darion-yaphet requested a review from mnriem as a code owner May 14, 2026 02:50
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