-
Notifications
You must be signed in to change notification settings - Fork 97
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
Implement #139: Bump version inside VersionInfo #141
Implement #139: Bump version inside VersionInfo #141
Conversation
* Add bump_major, bump_minor, bump_patch, bump_prerelease and bump_build as methods in class VersionInfo. With this methods, it is now possible to write something like this: ```python ver = semver.parse_version_info("3.4.5") new_ver = ver.bump_major().bump_minor() ``` * Add test cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for quick PR :) I have only small remarks regarding docstrings
Co-authored-by: Karol "ppkt"
@ppkt I've implemented your suggestion in the above commits. Hope you are fine with that. 😉 Let me know if you prefer to squash the commits. By the way: what amount of lines do I need to change to qualify for the contributors file? 😉 |
Another question about consistency. I've found out that some docstring are written differently. Some docstrings have this style: def parse(version):
"""Parse version to major, minor, patch, pre-release, build parts.
:param version: version string
:return: dictionary with the keys 'build', 'major', 'minor', 'patch',
and 'prerelease'. The prerelease or build keys can be None
if not provided
:rtype: dict
>>> import semver
>>> ver = semver.parse('3.4.5-pre.2+build.4')
>>> # [...]
""" while others have this style: def bump_major(self):
"""Raise the major part of the version, return a new object
but leave self untouched
:return: new object with the raised major part
:rtype: VersionInfo
>>> import semver
>>> ver = semver.parse_version_info("3.4.5")
>>> ver.bump_major()
VersionInfo(major=4, minor=0, patch=0, prerelease=None, build=None)
""" Probably that was me to blame. 😢 To summarize: either we write doctests first and then all parameters, or vice versa. Is there any preferred style? IMHO, at least we should be consistent. I would like to fix that, but that's probably something for a different PR, right? |
@tomschr I think you can update docstrings in separate PR. Regarding "contributors" file - I don't think there is any limit - feel free to add yourself. And thank you for your PRs :) |
@ppkt Ok, will attack consistency of docstrings in another PR. 😉 Regarding contributors file, I will add myself in one of my open PRs. 😄 Thanks! |
This PR helps this quite old issue: #40 |
This PR implements #139
Add bump_major, bump_minor, bump_patch, bump_prerelease and bump_build as methods in class VersionInfo. With this methods, it is now possible to write something like this:
Add test cases
Some comments about this implementation:
semver.bump_major()
etc. to avoid implementing the same code (double code is bad code).@ppkt Karol, what do you think? :-)