Apply suggested fix to src/borg/version.py from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This commit is contained in:
TW 2026-05-22 11:52:59 +02:00 committed by GitHub
parent a3d32f8846
commit 147b7ef348
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,12 +38,19 @@ def format_version(version):
f = []
it = iter(version)
while True:
part = next(it)
try:
part = next(it)
except StopIteration:
raise ValueError("Invalid version tuple %r" % (version,))
if part >= 0:
f.append(str(part))
elif part == -1:
break
else:
f[-1] = f[-1] + {-2: "rc", -3: "b", -4: "a", -9: ".dev"}[part] + str(next(it))
try:
pnum = next(it)
except StopIteration:
raise ValueError("Invalid prerelease version tuple %r" % (version,))
f[-1] = f[-1] + {-2: "rc", -3: "b", -4: "a", -9: ".dev"}[part] + str(pnum)
break
return ".".join(f)