Skip to content

Move all hard-coded version constants into a central _fallback module#1481

Merged
nathanjmcdougall merged 6 commits intomainfrom
copilot/move-version-constants-module
Mar 25, 2026
Merged

Move all hard-coded version constants into a central _fallback module#1481
nathanjmcdougall merged 6 commits intomainfrom
copilot/move-version-constants-module

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

Version constants (FALLBACK_UV_VERSION, _RUFF_VERSION, PRE_COMMIT_VERSION, etc.) were scattered across 6 source files with their up-to-dateness tests spread across 5 test files. Centralizes both for simpler maintenance.

Changes

  • New src/usethis/_fallback.py — single source of truth for all 6 version constants, consistently renamed with the FALLBACK_ prefix:

    • FALLBACK_UV_VERSION, FALLBACK_PRE_COMMIT_VERSION, FALLBACK_RUFF_VERSION, FALLBACK_SYNC_WITH_UV_VERSION, FALLBACK_PYPROJECT_FMT_VERSION, FALLBACK_CODESPELL_VERSION
  • New tests/usethis/test_fallback.py — consolidates all GitHub-tag up-to-dateness tests with a shared _skip_on_github_error helper

  • Updated 6 source files to import from _fallback instead of defining constants locally

  • Updated 5 test files to remove moved tests and clean up now-unused imports

  • .importlinter — registered _fallback in the _types | errors layer

# Before: constants scattered across modules
# src/usethis/_tool/impl/base/ruff.py
_RUFF_VERSION = "v0.15.7"

# After: single central module with consistent FALLBACK_ prefix
# src/usethis/_fallback.py
FALLBACK_RUFF_VERSION = "v0.15.7"

# Consumers import from central module
from usethis._fallback import FALLBACK_RUFF_VERSION
Original prompt

This section details on the original issue you should resolve

<issue_title>Move all hard-coded version constants into a central module</issue_title>
<issue_description>Came up when reviewing #1469.

I'm thinking of FALLBACK_UV_VERSION etc. associated up-to-dateness tests should move into a new tests module.

This helps move toward simpler maintenance on this point.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 24, 2026 04:14
Create src/usethis/_versions.py consolidating all version constants:
- FALLBACK_UV_VERSION (from _backend/uv/version.py)
- PRE_COMMIT_VERSION (from _integrations/pre_commit/version.py)
- _RUFF_VERSION (from _tool/impl/base/ruff.py)
- _SYNC_WITH_UV_VERSION (from _tool/impl/spec/pre_commit.py)
- _PYPROJECT_FMT_VERSION (from _tool/impl/spec/pyproject_fmt.py)
- _CODESPELL_VERSION (from _tool/impl/spec/codespell.py)

Move all version up-to-dateness tests to tests/usethis/test_versions.py.
Update all imports across source and test files.

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/8d9c42f4-daba-4906-ad52-a2db630360ff
…ting

Remove leading underscores from version constants (now in _versions module):
- _RUFF_VERSION → RUFF_VERSION
- _SYNC_WITH_UV_VERSION → SYNC_WITH_UV_VERSION
- _PYPROJECT_FMT_VERSION → PYPROJECT_FMT_VERSION
- _CODESPELL_VERSION → CODESPELL_VERSION

Add _versions to import-linter layer configuration.
Apply auto-formatting fixes from ruff.

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/8d9c42f4-daba-4906-ad52-a2db630360ff
Copilot AI changed the title [WIP] Move all hard-coded version constants into a central module Move all hard-coded version constants into a central module Mar 24, 2026
Copilot AI requested a review from nathanjmcdougall March 24, 2026 04:21
@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

@copilot can we please rename these constants to have the FALLBACK_ prefix consistently?

Rename all version constants to have the FALLBACK_ prefix:
- PRE_COMMIT_VERSION → FALLBACK_PRE_COMMIT_VERSION
- RUFF_VERSION → FALLBACK_RUFF_VERSION
- SYNC_WITH_UV_VERSION → FALLBACK_SYNC_WITH_UV_VERSION
- PYPROJECT_FMT_VERSION → FALLBACK_PYPROJECT_FMT_VERSION
- CODESPELL_VERSION → FALLBACK_CODESPELL_VERSION

FALLBACK_UV_VERSION already had the prefix.

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/c3521af3-873e-4d25-bdfe-0f6462a5461b
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot can we please rename these constants to have the FALLBACK_ prefix consistently?

Done in 1cd109b. All constants now use the FALLBACK_ prefix consistently: FALLBACK_PRE_COMMIT_VERSION, FALLBACK_RUFF_VERSION, FALLBACK_SYNC_WITH_UV_VERSION, FALLBACK_PYPROJECT_FMT_VERSION, FALLBACK_CODESPELL_VERSION (and the already-prefixed FALLBACK_UV_VERSION).

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/cd749360-0035-4dad-81ab-87660c87081d
Copilot AI changed the title Move all hard-coded version constants into a central module Move all hard-coded version constants into a central _fallback module Mar 24, 2026
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review March 24, 2026 23:13
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 24, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/move-version-constants-module (75535fe) with main (baef774)

Open in CodSpeed

@nathanjmcdougall nathanjmcdougall merged commit 955929a into main Mar 25, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/move-version-constants-module branch March 25, 2026 00:22
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.

Move all hard-coded version constants into a central module

2 participants