Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #912 - ensure mypy safe version template #915

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading