Skip to content

Commit

Permalink
fix #912 - ensure mypy safe version template
Browse files Browse the repository at this point in the history
this also adds

* a regression test running mypy (unpinned)
* a regression tests running flake8 (unpinned)
  • Loading branch information
RonnyPfannschmidt committed Sep 20, 2023
1 parent 540f522 commit 6721735
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
v8.0.2
======

bugfix
------

* fix #912: ensure mypy safety of the version template + regression test


v8.0.1
======
Expand Down
2 changes: 2 additions & 0 deletions src/setuptools_scm/_integration/dump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
".py": """\
# file generated by setuptools_scm
# don't change, don't track in version control
from __future__ import annotations
__version__ = version = {version!r} # type: str
__version_tuple__ = version_tuple = {version_tuple!r} # type: tuple[int | str, ...]
""",
Expand Down
28 changes: 24 additions & 4 deletions testing/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,44 @@ def test_dump_version_modern(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) ->
assert target.read_text() == version


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

version = "1.2.3"
scm_version = meta(version, config=c)
write_version_to_path(
tmp_path / "VERSION.py", template=None, version=version, scm_version=scm_version
)


def test_dump_version_on_old_python(tmp_path: Path) -> None:
python37 = shutil.which("python3.7")
if python37 is None:
pytest.skip("python3.7 not found")
dump_a_version(tmp_path)
subprocess.run(
[python37, "-c", "import VERSION;print(VERSION.version)"],
cwd=tmp_path,
check=True,
)


def test_dump_version_mypy(tmp_path: Path) -> None:
mypy = shutil.which("mypy")
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)


def test_dump_version_flake8(tmp_path: Path) -> None:
flake8 = shutil.which("flake8")
if flake8 is None:
pytest.skip("flake8 not found")
dump_a_version(tmp_path)
subprocess.run([flake8, "VERSION.py"], cwd=tmp_path, check=True)


def test_has_command() -> None:
with pytest.warns(RuntimeWarning, match="yadayada"):
assert not has_command("yadayada_setuptools_aint_ne")
Expand Down

0 comments on commit 6721735

Please sign in to comment.