Skip to content

Commit 6beec52

Browse files
Merge pull request #915 from RonnyPfannschmidt/fix-912-version-template-type-annotations
fix #912 - ensure mypy safe version template
2 parents 540f522 + 6721735 commit 6beec52

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
v8.0.2
2+
======
3+
4+
bugfix
5+
------
6+
7+
* fix #912: ensure mypy safety of the version template + regression test
8+
19

210
v8.0.1
311
======

src/setuptools_scm/_integration/dump_version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
".py": """\
1616
# file generated by setuptools_scm
1717
# don't change, don't track in version control
18+
from __future__ import annotations
19+
1820
__version__ = version = {version!r} # type: str
1921
__version_tuple__ = version_tuple = {version_tuple!r} # type: tuple[int | str, ...]
2022
""",

testing/test_functions.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,44 @@ def test_dump_version_modern(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) ->
110110
assert target.read_text() == version
111111

112112

113-
def test_dump_version_on_old_python(tmp_path: Path) -> None:
114-
python37 = shutil.which("python3.7")
115-
if python37 is None:
116-
pytest.skip("python3.7 not found")
113+
def dump_a_version(tmp_path: Path) -> None:
117114
from setuptools_scm._integration.dump_version import write_version_to_path
118115

119116
version = "1.2.3"
120117
scm_version = meta(version, config=c)
121118
write_version_to_path(
122119
tmp_path / "VERSION.py", template=None, version=version, scm_version=scm_version
123120
)
121+
122+
123+
def test_dump_version_on_old_python(tmp_path: Path) -> None:
124+
python37 = shutil.which("python3.7")
125+
if python37 is None:
126+
pytest.skip("python3.7 not found")
127+
dump_a_version(tmp_path)
124128
subprocess.run(
125129
[python37, "-c", "import VERSION;print(VERSION.version)"],
126130
cwd=tmp_path,
127131
check=True,
128132
)
129133

130134

135+
def test_dump_version_mypy(tmp_path: Path) -> None:
136+
mypy = shutil.which("mypy")
137+
if mypy is None:
138+
pytest.skip("mypy not found")
139+
dump_a_version(tmp_path)
140+
subprocess.run([mypy, "--strict", "VERSION.py"], cwd=tmp_path, check=True)
141+
142+
143+
def test_dump_version_flake8(tmp_path: Path) -> None:
144+
flake8 = shutil.which("flake8")
145+
if flake8 is None:
146+
pytest.skip("flake8 not found")
147+
dump_a_version(tmp_path)
148+
subprocess.run([flake8, "VERSION.py"], cwd=tmp_path, check=True)
149+
150+
131151
def test_has_command() -> None:
132152
with pytest.warns(RuntimeWarning, match="yadayada"):
133153
assert not has_command("yadayada_setuptools_aint_ne")

0 commit comments

Comments
 (0)