Skip to content

Commit 1cd109b

Browse files
Rename version constants to use 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
1 parent 0ab0874 commit 1cd109b

9 files changed

Lines changed: 45 additions & 45 deletions

File tree

src/usethis/_integrations/pre_commit/version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
from usethis._config import usethis_config
22
from usethis._integrations.pre_commit.yaml import PreCommitConfigYAMLManager
3-
from usethis._versions import PRE_COMMIT_VERSION
3+
from usethis._versions import FALLBACK_PRE_COMMIT_VERSION
44

55

66
def get_pre_commit_version() -> str:
77
"""Get an inferred pre-commit version for usethis to target.
88
99
If no version can be inferred, a hard-coded version is used, corresponding to a
10-
recent release (see `PRE_COMMIT_VERSION`).
10+
recent release (see `FALLBACK_PRE_COMMIT_VERSION`).
1111
"""
1212
version = get_minimum_pre_commit_version()
1313
if version is not None:
1414
return version
15-
return PRE_COMMIT_VERSION
15+
return FALLBACK_PRE_COMMIT_VERSION
1616

1717

1818
def get_minimum_pre_commit_version() -> str | None:

src/usethis/_tool/impl/base/ruff.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from usethis._tool.pre_commit import PreCommitConfig, PreCommitRepoConfig
2929
from usethis._tool.rule import Rule
3030
from usethis._types.backend import BackendEnum
31-
from usethis._versions import RUFF_VERSION
31+
from usethis._versions import FALLBACK_RUFF_VERSION
3232

3333
if TYPE_CHECKING:
3434
from collections.abc import Sequence
@@ -109,7 +109,7 @@ def pre_commit_config(self) -> PreCommitConfig:
109109
PreCommitRepoConfig(
110110
repo=pre_commit_schema.UriRepo(
111111
repo="https://github.com/astral-sh/ruff-pre-commit",
112-
rev=RUFF_VERSION,
112+
rev=FALLBACK_RUFF_VERSION,
113113
hooks=[pre_commit_schema.HookDefinition(id="ruff-check")],
114114
),
115115
requires_venv=False,
@@ -120,7 +120,7 @@ def pre_commit_config(self) -> PreCommitConfig:
120120
PreCommitRepoConfig(
121121
repo=pre_commit_schema.UriRepo(
122122
repo="https://github.com/astral-sh/ruff-pre-commit",
123-
rev=RUFF_VERSION,
123+
rev=FALLBACK_RUFF_VERSION,
124124
hooks=[pre_commit_schema.HookDefinition(id="ruff-format")],
125125
),
126126
requires_venv=False,

src/usethis/_tool/impl/spec/codespell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from usethis._tool.config import ConfigEntry, ConfigItem, ConfigSpec
2121
from usethis._tool.pre_commit import PreCommitConfig
2222
from usethis._types.deps import Dependency
23-
from usethis._versions import CODESPELL_VERSION
23+
from usethis._versions import FALLBACK_CODESPELL_VERSION
2424

2525
if TYPE_CHECKING:
2626
from usethis._file.manager import KeyValueFileManager
@@ -76,7 +76,7 @@ def pre_commit_config(self) -> PreCommitConfig:
7676
return PreCommitConfig.from_single_repo(
7777
pre_commit_schema.UriRepo(
7878
repo="https://github.com/codespell-project/codespell",
79-
rev=CODESPELL_VERSION,
79+
rev=FALLBACK_CODESPELL_VERSION,
8080
hooks=[
8181
pre_commit_schema.HookDefinition(
8282
id="codespell", additional_dependencies=["tomli"]

src/usethis/_tool/impl/spec/pre_commit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from usethis._tool.pre_commit import PreCommitConfig
1313
from usethis._types.backend import BackendEnum
1414
from usethis._types.deps import Dependency
15-
from usethis._versions import SYNC_WITH_UV_VERSION
15+
from usethis._versions import FALLBACK_SYNC_WITH_UV_VERSION
1616

1717

1818
class PreCommitToolSpec(ToolSpec):
@@ -46,7 +46,7 @@ def pre_commit_config(self) -> PreCommitConfig:
4646
return PreCommitConfig.from_single_repo(
4747
pre_commit_schema.UriRepo(
4848
repo="https://github.com/tsvikas/sync-with-uv",
49-
rev=SYNC_WITH_UV_VERSION,
49+
rev=FALLBACK_SYNC_WITH_UV_VERSION,
5050
hooks=[pre_commit_schema.HookDefinition(id="sync-with-uv")],
5151
),
5252
requires_venv=False,

src/usethis/_tool/impl/spec/pyproject_fmt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from usethis._tool.config import ConfigEntry, ConfigItem, ConfigSpec
1212
from usethis._tool.pre_commit import PreCommitConfig
1313
from usethis._types.deps import Dependency
14-
from usethis._versions import PYPROJECT_FMT_VERSION
14+
from usethis._versions import FALLBACK_PYPROJECT_FMT_VERSION
1515

1616

1717
class PyprojectFmtToolSpec(ToolSpec):
@@ -41,7 +41,7 @@ def pre_commit_config(self) -> PreCommitConfig:
4141
return PreCommitConfig.from_single_repo(
4242
pre_commit_schema.UriRepo(
4343
repo="https://github.com/tox-dev/pyproject-fmt",
44-
rev=PYPROJECT_FMT_VERSION,
44+
rev=FALLBACK_PYPROJECT_FMT_VERSION,
4545
hooks=[pre_commit_schema.HookDefinition(id="pyproject-fmt")],
4646
),
4747
requires_venv=False,

src/usethis/_versions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"""
77

88
FALLBACK_UV_VERSION = "0.10.12"
9-
PRE_COMMIT_VERSION = "4.5.1"
10-
RUFF_VERSION = "v0.15.7"
11-
SYNC_WITH_UV_VERSION = "v0.5.0"
12-
PYPROJECT_FMT_VERSION = "v2.20.0"
13-
CODESPELL_VERSION = "v2.4.2"
9+
FALLBACK_PRE_COMMIT_VERSION = "4.5.1"
10+
FALLBACK_RUFF_VERSION = "v0.15.7"
11+
FALLBACK_SYNC_WITH_UV_VERSION = "v0.5.0"
12+
FALLBACK_PYPROJECT_FMT_VERSION = "v2.20.0"
13+
FALLBACK_CODESPELL_VERSION = "v2.4.2"

tests/usethis/_core/test_core_tool.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from usethis._tool.impl.base.ruff import RuffTool
4141
from usethis._types.backend import BackendEnum
4242
from usethis._types.deps import Dependency
43-
from usethis._versions import RUFF_VERSION, SYNC_WITH_UV_VERSION
43+
from usethis._versions import FALLBACK_RUFF_VERSION, FALLBACK_SYNC_WITH_UV_VERSION
4444

4545

4646
class TestAllHooksList:
@@ -725,7 +725,7 @@ def test_pre_commit_after(
725725
f"""\
726726
repos:
727727
- repo: https://github.com/tsvikas/sync-with-uv
728-
rev: {SYNC_WITH_UV_VERSION}
728+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
729729
hooks:
730730
- id: sync-with-uv
731731
- repo: local
@@ -893,7 +893,7 @@ def test_pre_commit_first(
893893
f"""\
894894
repos:
895895
- repo: https://github.com/tsvikas/sync-with-uv
896-
rev: {SYNC_WITH_UV_VERSION}
896+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
897897
hooks:
898898
- id: sync-with-uv
899899
- repo: local
@@ -1907,7 +1907,7 @@ def test_fresh(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
19071907
f"""\
19081908
repos:
19091909
- repo: https://github.com/tsvikas/sync-with-uv
1910-
rev: {SYNC_WITH_UV_VERSION}
1910+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
19111911
hooks:
19121912
- id: sync-with-uv
19131913
"""
@@ -1985,7 +1985,7 @@ def test_config_file_already_exists(self, uv_init_repo_dir: Path):
19851985
entry: uv run --isolated --frozen --offline python -c "print('hello world!')"
19861986
language: system
19871987
- repo: https://github.com/tsvikas/sync-with-uv
1988-
rev: {SYNC_WITH_UV_VERSION}
1988+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
19891989
hooks:
19901990
- id: sync-with-uv
19911991
"""
@@ -3435,7 +3435,7 @@ def test_pre_commit(
34353435
f"""\
34363436
repos:
34373437
- repo: https://github.com/tsvikas/sync-with-uv
3438-
rev: {SYNC_WITH_UV_VERSION}
3438+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
34393439
hooks:
34403440
- id: sync-with-uv
34413441
- repo: local
@@ -3961,11 +3961,11 @@ def test_add_only_linter(
39613961
f"""\
39623962
repos:
39633963
- repo: https://github.com/tsvikas/sync-with-uv
3964-
rev: {SYNC_WITH_UV_VERSION}
3964+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
39653965
hooks:
39663966
- id: sync-with-uv
39673967
- repo: https://github.com/astral-sh/ruff-pre-commit
3968-
rev: {RUFF_VERSION}
3968+
rev: {FALLBACK_RUFF_VERSION}
39693969
hooks:
39703970
- id: ruff-check
39713971
"""
@@ -3999,15 +3999,15 @@ def test_add_only_linter_to_existing_formatter(
39993999
f"""\
40004000
repos:
40014001
- repo: https://github.com/tsvikas/sync-with-uv
4002-
rev: {SYNC_WITH_UV_VERSION}
4002+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
40034003
hooks:
40044004
- id: sync-with-uv
40054005
- repo: https://github.com/astral-sh/ruff-pre-commit
4006-
rev: {RUFF_VERSION}
4006+
rev: {FALLBACK_RUFF_VERSION}
40074007
hooks:
40084008
- id: ruff-check
40094009
- repo: https://github.com/astral-sh/ruff-pre-commit
4010-
rev: {RUFF_VERSION}
4010+
rev: {FALLBACK_RUFF_VERSION}
40114011
hooks:
40124012
- id: ruff-format
40134013
"""
@@ -4040,11 +4040,11 @@ def test_add_only_formatter(
40404040
f"""\
40414041
repos:
40424042
- repo: https://github.com/tsvikas/sync-with-uv
4043-
rev: {SYNC_WITH_UV_VERSION}
4043+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
40444044
hooks:
40454045
- id: sync-with-uv
40464046
- repo: https://github.com/astral-sh/ruff-pre-commit
4047-
rev: {RUFF_VERSION}
4047+
rev: {FALLBACK_RUFF_VERSION}
40484048
hooks:
40494049
- id: ruff-format
40504050
"""
@@ -4078,11 +4078,11 @@ def test_remove_only_linter(
40784078
f"""\
40794079
repos:
40804080
- repo: https://github.com/tsvikas/sync-with-uv
4081-
rev: {SYNC_WITH_UV_VERSION}
4081+
rev: {FALLBACK_SYNC_WITH_UV_VERSION}
40824082
hooks:
40834083
- id: sync-with-uv
40844084
- repo: https://github.com/astral-sh/ruff-pre-commit
4085-
rev: {RUFF_VERSION}
4085+
rev: {FALLBACK_RUFF_VERSION}
40864086
hooks:
40874087
- id: ruff-format
40884088
"""

tests/usethis/_integrations/pre_commit/test_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
get_pre_commit_version,
77
)
88
from usethis._test import change_cwd
9-
from usethis._versions import PRE_COMMIT_VERSION
9+
from usethis._versions import FALLBACK_PRE_COMMIT_VERSION
1010

1111

1212
class TestGetMinimumPreCommitVersion:
@@ -79,7 +79,7 @@ def test_falls_back_to_hardcoded_when_config_doesnt_exist(self, tmp_path: Path):
7979
result = get_pre_commit_version()
8080

8181
# Assert
82-
assert result == PRE_COMMIT_VERSION
82+
assert result == FALLBACK_PRE_COMMIT_VERSION
8383

8484
def test_falls_back_to_hardcoded_when_minimum_not_declared(self, tmp_path: Path):
8585
# Arrange
@@ -96,4 +96,4 @@ def test_falls_back_to_hardcoded_when_minimum_not_declared(self, tmp_path: Path)
9696
result = get_pre_commit_version()
9797

9898
# Assert
99-
assert result == PRE_COMMIT_VERSION
99+
assert result == FALLBACK_PRE_COMMIT_VERSION

tests/usethis/test_versions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
from usethis._integrations.ci.github.errors import GitHubTagError
77
from usethis._integrations.ci.github.tags import get_github_latest_tag
88
from usethis._versions import (
9-
CODESPELL_VERSION,
9+
FALLBACK_CODESPELL_VERSION,
10+
FALLBACK_PRE_COMMIT_VERSION,
11+
FALLBACK_PYPROJECT_FMT_VERSION,
12+
FALLBACK_RUFF_VERSION,
13+
FALLBACK_SYNC_WITH_UV_VERSION,
1014
FALLBACK_UV_VERSION,
11-
PRE_COMMIT_VERSION,
12-
PYPROJECT_FMT_VERSION,
13-
RUFF_VERSION,
14-
SYNC_WITH_UV_VERSION,
1515
)
1616

1717

@@ -49,7 +49,7 @@ def test_latest_version(self):
4949
try:
5050
assert (
5151
get_github_latest_tag(owner="pre-commit", repo="pre-commit")
52-
== f"v{PRE_COMMIT_VERSION}"
52+
== f"v{FALLBACK_PRE_COMMIT_VERSION}"
5353
)
5454
except GitHubTagError as err:
5555
_skip_on_github_error(err)
@@ -65,7 +65,7 @@ def test_latest_version(self):
6565
try:
6666
assert (
6767
get_github_latest_tag(owner="astral-sh", repo="ruff-pre-commit")
68-
== RUFF_VERSION
68+
== FALLBACK_RUFF_VERSION
6969
)
7070
except GitHubTagError as err:
7171
_skip_on_github_error(err)
@@ -81,7 +81,7 @@ def test_latest_version(self):
8181
try:
8282
assert (
8383
get_github_latest_tag(owner="tsvikas", repo="sync-with-uv")
84-
== SYNC_WITH_UV_VERSION
84+
== FALLBACK_SYNC_WITH_UV_VERSION
8585
)
8686
except GitHubTagError as err:
8787
_skip_on_github_error(err)
@@ -97,7 +97,7 @@ def test_latest_version(self):
9797
try:
9898
assert (
9999
get_github_latest_tag(owner="codespell-project", repo="codespell")
100-
== CODESPELL_VERSION
100+
== FALLBACK_CODESPELL_VERSION
101101
)
102102
except GitHubTagError as err:
103103
_skip_on_github_error(err)
@@ -115,7 +115,7 @@ def test_latest_version(self):
115115
# at https://github.com/tox-dev/toml-fmt/tree/main/pyproject-fmt
116116
assert (
117117
get_github_latest_tag(owner="tox-dev", repo="pyproject-fmt")
118-
== PYPROJECT_FMT_VERSION
118+
== FALLBACK_PYPROJECT_FMT_VERSION
119119
)
120120
except GitHubTagError as err:
121121
_skip_on_github_error(err)

0 commit comments

Comments
 (0)