VersionInfo should support string output
See original GitHub issueIt may seem weird, but the VersionInfo object lacks the “opposite” thing of parsing a SemVer. I just like to have a str output like “3.0.0” from a VersionInfo - this is not implemented. Wouldn’t it be nice to have something like
def to_str(self):
return self.format_version(
self.major,
self.minor,
self.patch,
self.prerelease,
self.build
)
So if you have a VersionInfo object you can print out the original/created string again (for saving in a DB e.g.):
>>> version = VersionInfo(3, 4, 5)
>>> print(version.to_str())
3.4.5
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
string interpolation - format string output - Microsoft Learn
To identify a string literal as an interpolated string, prepend it with the $ symbol. You can't have any white space between the...
Read more >Standard way to embed version into Python package?
I would imagine there's some way to retrieve that data without any extra hardcoding, since minor/major strings are specified in setup.py already. Alternative ......
Read more >7. Input and Output — Python 3.11.1 documentation
The str.format() method of strings requires more manual effort. You'll still use { and } to mark where a variable will be substituted...
Read more >A Guide to Formatting with f-strings in Python - CIS Sandbox
f-strings support extensive modifiers that control the final appearance of the output string. Expressions in f-strings can be modified by a format specification ......
Read more >Declaring Versions and Ranges - Gradle User Manual
Gradle supports different ways of declaring a version string: ... This means that [1.0, 2.0[ will also exclude all versions starting with 2.0...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Indeed, that was fixed in https://github.com/k-bx/python-semver/commit/7fdf7b242dd993aa7a0b22821f94379ac8d983d4
@scls19fr how about new release?
Related issue https://github.com/k-bx/python-semver/issues/98
2.8.1 version is now available