Skip to content

Commit bf38410

Browse files
authored
Merge pull request #1 from ichrysou/feature/allow_str_formatting_for_serialized_version_parts
format version parts
2 parents f4e0334 + ee43bdb commit bf38410

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bumpversion/version_part.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ def is_independent(self) -> bool:
6060
return self.config.independent
6161

6262
def __format__(self, format_spec: str) -> str:
63-
return self.value
63+
try:
64+
val = int(self.value)
65+
except ValueError:
66+
return self.value
67+
else:
68+
return int.__format__(val, format_spec)
6469

6570
def __repr__(self) -> str:
6671
return f"<bumpversion.VersionPart:{self.func.__class__.__name__}:{self.value}>"

0 commit comments

Comments
 (0)