Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self._patch:
new_patch = self._patch - 1
new_minor = self._minor
new_major = self._major
else:
new_patch = 9999
if self._minor:
new_minor = self._minor - 1
new_major = self._major
else:
new_minor = 9999
if self._major:
new_major = self._major - 1
else:
new_major = 0
return SemanticVersion(
new_major, new_minor, new_patch)
if minor:
new_minor = self._minor + 1
new_patch = 0
new_prerelease_type = None
new_prerelease = None
else:
new_minor = self._minor
if major:
new_major = self._major + 1
new_minor = 0
new_patch = 0
new_prerelease_type = None
new_prerelease = None
else:
new_major = self._major
return SemanticVersion(
new_major, new_minor, new_patch,
new_prerelease_type, new_prerelease)
# Current RC/beta layout
prerelease_type, prerelease = _parse_type(remainder[0])
remainder = remainder[1:]
while remainder:
component = remainder[0]
if component.startswith('dev'):
dev_count = int(component[3:])
elif component.startswith('post'):
dev_count = None
post_count = int(component[4:])
else:
raise ValueError(
'Unknown remainder %r in %r'
% (remainder, version_string))
remainder = remainder[1:]
result = SemanticVersion(
major, minor, patch, prerelease_type=prerelease_type,
prerelease=prerelease, dev_count=dev_count)
if post_count:
if dev_count:
raise ValueError(
'Cannot combine postN and devN - no mapping in %r'
% (version_string,))
result = result.increment().to_dev(post_count)
return result
def to_dev(self, dev_count):
"""Return a development version of this semver.
:param dev_count: The number of commits since the last release.
"""
return SemanticVersion(
self._major, self._minor, self._patch, self._prerelease_type,
self._prerelease, dev_count=dev_count)