Skip to content

Commit

Permalink
fix #926: ensure version file is mypy safe on python3.8gi
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Sep 22, 2023
1 parent 699313a commit 26fc104
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
======
Expand Down
6 changes: 4 additions & 2 deletions src/setuptools_scm/_integration/dump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
}
Expand Down
2 changes: 1 addition & 1 deletion testing/test_basic_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion testing/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 26fc104

Please sign in to comment.