From: Daniele Varrazzo Date: Sat, 2 Sep 2023 10:41:45 +0000 (+0100) Subject: refactor(bump_version): do without parse_version function X-Git-Tag: pool-3.2.0~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69939f722fcd484ae840129a1533d788ba8924d6;p=thirdparty%2Fpsycopg.git refactor(bump_version): do without parse_version function Also allow for no change in the change log found (mostly for testing). --- diff --git a/tools/bump_version.py b/tools/bump_version.py index 937368eec..8eda61aba 100755 --- a/tools/bump_version.py +++ b/tools/bump_version.py @@ -14,7 +14,7 @@ from argparse import ArgumentParser, Namespace from functools import cached_property from dataclasses import dataclass -from packaging.version import parse as parse_version, Version +from packaging.version import Version PROJECT_DIR = Path(__file__).parent.parent @@ -171,8 +171,7 @@ chore: bump {self.package.name} package version to {self.want_version} elif len(matches) > 1: raise ValueError(f"more than one version found in {fp}") - vs = parse_version(matches[0].group("ver")) - assert isinstance(vs, Version) + vs = Version(matches[0].group("ver")) return vs def _update_version_in_file(self, fp: Path, version: Version) -> None: @@ -236,6 +235,10 @@ chore: bump {self.package.name} package version to {self.want_version} lines = f.readlines() lns = self._find_lines(r"^[^\s]+ " + re.escape(str(version)), lines) + if not lns: + logger.warning("no change log line found") + return [] + assert len(lns) == 1 start = end = lns[0] + 3 while lines[end].rstrip():