Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VersionInfo should support string output #100

Closed
nerdoc opened this issue Jul 9, 2018 · 6 comments
Closed

VersionInfo should support string output #100

nerdoc opened this issue Jul 9, 2018 · 6 comments

Comments

@nerdoc
Copy link

nerdoc commented Jul 9, 2018

It 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
@kxepal
Copy link
Contributor

kxepal commented Jul 9, 2018

str(VersionInfo(3, 4, 5)) should works as expected. Or it doesn't?

@nerdoc
Copy link
Author

nerdoc commented Jul 9, 2018

OMG, yes. Sorry for the spam.

@nerdoc nerdoc closed this as completed Jul 9, 2018
@kxepal
Copy link
Contributor

kxepal commented Jul 9, 2018

No worries (:

@nerdoc
Copy link
Author

nerdoc commented Jul 9, 2018

BTW - VersionInfo(3,4,5) is not possible in 2.8.0 (my installed version using pip):

TypeError: __new__() missing 2 required positional arguments: 'prerelease' and 'build'

VersionInfo(3,4,5,0,0) is needed
You changed a few things in 2.8.1 ;-)

@kxepal
Copy link
Contributor

kxepal commented Jul 9, 2018

Indeed, that was fixed in 7fdf7b2

@scls19fr how about new release?

@scls19fr
Copy link
Member

scls19fr commented Jul 9, 2018

Related issue #98

2.8.1 version is now available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants