Skip to content

Commit 26fc104

Browse files
fix #926: ensure version file is mypy safe on python3.8gi
1 parent 699313a commit 26fc104

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ v8.0.3
22
======
33

44
* fix #918 for good - remove external importlib-metadata to avoid source only loop
5+
* fix #926: ensure mypy on python3.8 works with the version file
56

67
v8.0.2
78
======

src/setuptools_scm/_integration/dump_version.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
".py": """\
1616
# file generated by setuptools_scm
1717
# don't change, don't track in version control
18-
from __future__ import annotations
18+
TYPE_CHECKING = False
19+
if TYPE_CHECKING:
20+
from typing import Tuple
1921
2022
__version__ = version = {version!r} # type: str
21-
__version_tuple__ = version_tuple = {version_tuple!r} # type: tuple[int | str, ...]
23+
__version_tuple__ = version_tuple = {version_tuple!r} # type: Tuple[int | str, ...]
2224
""",
2325
".txt": "{version}",
2426
}

testing/test_basic_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def read(name: str) -> str:
182182
assert lines[-2:] == [
183183
"__version__ = version = '1.0.dev42' # type: str",
184184
"__version_tuple__ = version_tuple = (1, 0, 'dev42')"
185-
" # type: tuple[int | str, ...]",
185+
" # type: Tuple[int | str, ...]",
186186
]
187187

188188
version = "1.0.1+g4ac9d2c"

testing/test_functions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ def test_dump_version_mypy(tmp_path: Path) -> None:
137137
if mypy is None:
138138
pytest.skip("mypy not found")
139139
dump_a_version(tmp_path)
140-
subprocess.run([mypy, "--strict", "VERSION.py"], cwd=tmp_path, check=True)
140+
subprocess.run(
141+
[mypy, "--python-version=3.8", "--strict", "VERSION.py"],
142+
cwd=tmp_path,
143+
check=True,
144+
)
141145

142146

143147
def test_dump_version_flake8(tmp_path: Path) -> None:

0 commit comments

Comments
 (0)