question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bump version inside VersionInfo directly

See original GitHub issue

Situation

Hope I don’t miss anything, but reading the source code didn’t give a solution. It seems to me, dealing with version numbers and raising parts of it can actually quite tricky.

For example, let’s assume you’ve created a version like this:

ver = semver.parse_version_info("3.4.5")

How can you raise the major part? How the minor part? The ver variable is of type VersionInfo. You can’t directly use semver.bump_major or semver.bump_minor as they accept strings only. Nor does the class provide any methods. However, you could do something like that:

semver.bump_major(str(ver))

This works, but your VersionInfo type is converted into a string. Not good if you want to keep the type. If you want it back, you need to write:

semver.parse_version_info(semver.bump_major(str(ver)))

Not very pythonic. 😉

Possible Solution(s)

From what I can see, we have a good class, but we can’t raise parts individually. I think, this is gap. I could think of these solutions:

  1. Allow semver.bump_major and the other bump functions allow a VersionInfo type.
  2. Extend the VersionInfo class with additional methods like inc_major(), inc_minor() etc.
  3. Something else?

At the moment, I think number 2 can be a possible solution. Theoretically, you could name them also bump_major, but that could confuse people.

The above could be rewritten like that:

ver.inc_major()

If we go with this, there are two possible ways how this function could work:

  1. Return the raised version of ver but leave ver itself untouched.
  2. Return nothing (=None) and raise the part directly in ver.

Solution 1 could be interesting as it would allow to write something like this:

new_ver = ver.inc_major().inc_minor()

What do you think?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ppktcommented, Sep 30, 2019

@tomschr it’s an interesting use case - I’ve never thought about it. I think, from user point of view, better approach is to use regular method and return updated object (as you suggested) and forget about class method 😃

1reaction
tomschrcommented, Oct 2, 2019

Uups, this was already fixed in commit a598059, but wasn’t closed automatically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

peritus/bumpversion: Version-bump your software ... - GitHub
Version -bump your software with a single command! A small command line tool to simplify releasing software by updating all version strings in...
Read more >
How to manage the version number in Git? - Stack Overflow
Another solution can be to use Git tags to automatically generate the version number. A script can find the closest tag starting with...
Read more >
7. Releasing and versioning - Python Packages
Python Semantic Release (PSR ) is a tool that can automatically bump version numbers based on keywords it finds in commit messages.
Read more >
Updating version info (Libtool) - GNU.org
In this case, bump revision only, don't touch current nor age . Programs using the previous version may use the new version as...
Read more >
Versioning using bumpversion - William Hayes, PhD
Bumpversion (use bump2version instead — it installs a command called bumpversion) is a python-based tool that you can use to manage semantic versioning...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found