From 53503786bb8bd1e101189363983699d196a53b03 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Fri, 1 Aug 2025 14:09:51 +0200 Subject: [PATCH] dont infer version in cli if --no-version is given closes #873 --- CHANGELOG.md | 1 + src/setuptools_scm/_cli.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea5b652f..ca407920 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - fix #501: add py.typed - fix #804: git - use fallback version instead of 0.0 when no version is found at all - fix #1139: use logging.lastResort instead of a own replica to avoid polluting logging._handlerList +- fix #873: don't infer version in cli if --no-version is given ## v8.3.1 diff --git a/src/setuptools_scm/_cli.py b/src/setuptools_scm/_cli.py index b54903a4..3f33f83d 100644 --- a/src/setuptools_scm/_cli.py +++ b/src/setuptools_scm/_cli.py @@ -33,10 +33,13 @@ def main(args: list[str] | None = None) -> int: file=sys.stderr, ) config = Configuration(root=inferred_root) - - version = _get_version( - config, force_write_version_files=opts.force_write_version_files - ) + version: str | None + if opts.no_version: + version = "0.0.0+no-version-was-requested.fake-version" + else: + version = _get_version( + config, force_write_version_files=opts.force_write_version_files + ) if version is None: raise SystemExit("ERROR: no version found for", opts) if opts.strip_dev: