diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 14dfe14d..6e9212d0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,7 @@ v8.0.3 ====== * fix #918 for good - remove external importlib-metadata to avoid source only loop +* fix #926: ensure mypy on python3.8 works with the version file v8.0.2 ====== diff --git a/src/setuptools_scm/_integration/dump_version.py b/src/setuptools_scm/_integration/dump_version.py index 1dd280b9..36790fa8 100644 --- a/src/setuptools_scm/_integration/dump_version.py +++ b/src/setuptools_scm/_integration/dump_version.py @@ -15,10 +15,12 @@ ".py": """\ # file generated by setuptools_scm # don't change, don't track in version control -from __future__ import annotations +TYPE_CHECKING = False +if TYPE_CHECKING: + from typing import Tuple __version__ = version = {version!r} # type: str -__version_tuple__ = version_tuple = {version_tuple!r} # type: tuple[int | str, ...] +__version_tuple__ = version_tuple = {version_tuple!r} # type: Tuple[int | str, ...] """, ".txt": "{version}", } diff --git a/testing/test_basic_api.py b/testing/test_basic_api.py index 95afa0f3..3af099a3 100644 --- a/testing/test_basic_api.py +++ b/testing/test_basic_api.py @@ -182,7 +182,7 @@ def read(name: str) -> str: assert lines[-2:] == [ "__version__ = version = '1.0.dev42' # type: str", "__version_tuple__ = version_tuple = (1, 0, 'dev42')" - " # type: tuple[int | str, ...]", + " # type: Tuple[int | str, ...]", ] version = "1.0.1+g4ac9d2c" diff --git a/testing/test_functions.py b/testing/test_functions.py index f7a74812..afa45d3b 100644 --- a/testing/test_functions.py +++ b/testing/test_functions.py @@ -137,7 +137,11 @@ def test_dump_version_mypy(tmp_path: Path) -> None: if mypy is None: pytest.skip("mypy not found") dump_a_version(tmp_path) - subprocess.run([mypy, "--strict", "VERSION.py"], cwd=tmp_path, check=True) + subprocess.run( + [mypy, "--python-version=3.8", "--strict", "VERSION.py"], + cwd=tmp_path, + check=True, + ) def test_dump_version_flake8(tmp_path: Path) -> None: