From baff4ddac3dca75d95d35b4961c10a8d095039ae Mon Sep 17 00:00:00 2001 From: Evan Sultanik Date: Wed, 9 Sep 2026 10:14:16 -0400 Subject: [PATCH] Print the raw version string for -dumpversion The -dumpversion option exists so that scripts can read Graphtage's version from STDOUT. It built its output by joining over version.__version__, which was once a tuple of version components. That attribute is now the string "0.3.1", so the join walked its characters and separated each one, printing "0 . 3 . 1". Any script parsing that output saw a value it could not use as a version. Print version.VERSION_STRING instead. That is the spelling the --version option already uses, and its name states the type the option needs, so the two stay consistent and a future change to the version's representation cannot silently reintroduce the same failure. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa --- graphtage/__main__.py | 2 +- test/test_main.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/graphtage/__main__.py b/graphtage/__main__.py index 5d5783a..8171a5e 100644 --- a/graphtage/__main__.py +++ b/graphtage/__main__.py @@ -217,7 +217,7 @@ def main(argv=None) -> int: exit(EXIT_ERROR) if args.dumpversion: - print(' '.join(map(str, version.__version__))) + print(version.VERSION_STRING) exit(0) if args.version: diff --git a/test/test_main.py b/test/test_main.py index 0072b94..398fed6 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -5,6 +5,7 @@ import tempfile import unittest +from graphtage import version from graphtage.__main__ import EXIT_DIFFERENCES_FOUND, EXIT_ERROR, EXIT_SUCCESS, main @@ -66,3 +67,12 @@ def test_json5_parse_failure_is_an_error(self): to_path = self.write('two.json5', '{a: 1,\n') status, _ = self.run_graphtage(from_path, to_path) self.assertEqual(EXIT_ERROR, status) + + def test_dumpversion_prints_a_bare_version_string(self): + """`-dumpversion` joined over the version string, so it printed `0 . 3 . 1` instead of `0.3.1`.""" + out = io.StringIO() + with contextlib.redirect_stdout(out), contextlib.redirect_stderr(io.StringIO()), \ + self.assertRaises(SystemExit) as exited: + main(['graphtage', '-dumpversion']) + self.assertEqual(EXIT_SUCCESS, exited.exception.code) + self.assertEqual(version.VERSION_STRING, out.getvalue().strip())