From e00fb6da0b0a2cec8fdb8ca89ba78b086157f6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Tue, 28 Feb 2023 11:01:01 +0100 Subject: Test and fix Version.truncate() Calling `Version.truncate("build")` should return a fresh instance, as caught in #141 Closes: #141, #142 --- semantic_version/base.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'semantic_version') diff --git a/semantic_version/base.py b/semantic_version/base.py index 777c27a..1c10155 100644 --- a/semantic_version/base.py +++ b/semantic_version/base.py @@ -181,7 +181,14 @@ class Version(object): def truncate(self, level='patch'): """Return a new Version object, truncated up to the selected level.""" if level == 'build': - return self + return Version( + major=self.major, + minor=self.minor, + patch=self.patch, + prerelease=self.prerelease, + build=self.build, + partial=self.partial, + ) elif level == 'prerelease': return Version( major=self.major, -- cgit v1.2.1