Skip to content

Commit b35dea9

Browse files
refactor: use unquoted modern type annotations in version template
Remove quotes from type annotations. With 'from __future__ import annotations', all annotations are automatically deferred, so no quotes needed. Changes: - vcs-versioning/src/vcs_versioning/_dump_version.py: - tuple[int | str, ...] instead of "tuple[int | str, ...]" - str | None instead of "str | None" - Cleaner, more readable syntax - Works with mypy 1.11.2 checking Python 3.8 Result: Simpler, cleaner generated version files using modern Python syntax.
1 parent c1a78b3 commit b35dea9

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

setuptools-scm/testing_scm/test_functions.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ def test_dump_version_on_old_python(tmp_path: Path) -> None:
9292

9393

9494
def test_dump_version_mypy(tmp_path: Path) -> None:
95-
mypy = shutil.which("mypy")
96-
if mypy is None:
97-
pytest.skip("mypy not found")
95+
uvx = shutil.which("uvx")
96+
if uvx is None:
97+
pytest.skip("uvx not found")
9898
dump_a_version(tmp_path)
99+
# Use mypy 1.11.2 - last version supporting Python 3.8
99100
subprocess.run(
100-
[mypy, "--python-version=3.8", "--strict", "VERSION.py"],
101+
[uvx, "mypy==1.11.2", "--python-version=3.8", "--strict", "VERSION.py"],
101102
cwd=tmp_path,
102103
check=True,
103104
)

vcs-versioning/src/vcs_versioning/_dump_version.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,12 @@
3131
"commit_id",
3232
]
3333
34-
TYPE_CHECKING = False
35-
if TYPE_CHECKING:
36-
VERSION_TUPLE = tuple[int | str, ...]
37-
COMMIT_ID = str | None
38-
else:
39-
VERSION_TUPLE = object
40-
COMMIT_ID = object
41-
4234
version: str
4335
__version__: str
44-
__version_tuple__: VERSION_TUPLE
45-
version_tuple: VERSION_TUPLE
46-
commit_id: COMMIT_ID
47-
__commit_id__: COMMIT_ID
36+
__version_tuple__: tuple[int | str, ...]
37+
version_tuple: tuple[int | str, ...]
38+
commit_id: str | None
39+
__commit_id__: str | None
4840
4941
__version__ = version = {version!r}
5042
__version_tuple__ = version_tuple = {version_tuple!r}

0 commit comments

Comments
 (0)