summaryrefslogtreecommitdiff
path: root/semantic_version/base.py
Commit message (Collapse)AuthorAgeFilesLines
* Simplify subclassing VersionHEADsubclasseablemasterRaphaël Barrois2023-02-281-12/+12
| | | | Fixes: #112
* Test and fix Version.truncate()Raphaël Barrois2023-02-281-1/+8
| | | | | | | Calling `Version.truncate("build")` should return a fresh instance, as caught in #141 Closes: #141, #142
* Guarantee a stable ordering with build metadataRaphaël Barrois2022-05-261-7/+35
| | | | | | | | | | | | | Sorting any permutation of Version objects should always yield the same result, even if those hold some build metadata. To that end, the "precedence_key" is now used exclusively for sorting; direct comparisons between Version objects still ignores the "build" metadata, using a different precedence key. For performance improvements, both precedence keys are cached. Closes: #132
* Update the Version.parse() to match the codePhilippe Ombredanne2022-02-061-1/+2
| | | | | | The docstring was lying by saying a Version object was returned. Rather this function returns a tuple of version parts. Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* Fix wildcard matching for SimpleSpec.Raphaël Barrois2020-04-291-1/+1
| | | | | | Including docs and tests. Closes #98.
* Properly coerce versions with leading zeroes.Raphaël Barrois2019-12-211-0/+8
| | | | | | | A leading zero is forbidden in the SemVer spec, but could be valid under other schemes; when coercing, it can easily be removed. Closes #89, thanks to Andrew Ni for the report.
* Fix NpmSpec prerelease-handling.Raphaël Barrois2019-11-211-1/+2
| | | | | | | | | | | | | Thanks to Nathan Walters for spotting this. Npm ranges with a `<X.Y.Z-P` component were not properly expanded: they were converted to: <X.Y.0 || (>=X.Y.0 && <X.Y.Z-P && no-prerelease) The correct expansion is: <X.Y.0 || (>=X.Y.0-* && <X.Y.Z-P) Closes #86.
* Add Clause.prettyprint() for debug.Raphaël Barrois2019-11-211-0/+31
| | | | | | | | This function allows developers to preview the structure of the resulting clause parsed from a spec, usable with `print(spec.clause.prettyprint())`. Apply typical PEP8 indentation rules.
* Fix Spec.specs for single-term ranges.maint/2.xRaphaël Barrois2019-09-061-1/+5
| | | | | | | This (deprecated) property failed when used on a `Spec` item based on a single-term range (e.g. `==0.1.2` `<2.0.0`). Closes #82.
* Restore `Spec.specs` [Closes #79]Raphaël Barrois2019-08-291-0/+4
| | | | This attribute wasn't meant to be removed.
* Restore Python2 support.rbarrois/restore-py2Raphaël Barrois2019-08-291-14/+13
|
* Fix NPM-style caret matching.Raphaël Barrois2019-08-281-6/+10
|
* Deprecate support for 'partial' versions.rba/pre-2.8Raphaël Barrois2019-08-261-0/+6
| | | | | Their comparison semantics were ill-defined, and mostly an implementation detail for the old, 'native' specs.
* Add `Version.precedence_key`.Raphaël Barrois2019-08-261-152/+103
| | | | | | | | | | | | | | | | | | | This will be used in `sort(..., key=lambda v: v.precedence_key)`. Remove previous comparison/ordering implementation. The current implementation relies on a 4-tuple: - major, minor, patch (as integers) - natural order matches precedence rules - a tuple of identifiers for the prerelease component. The identifiers for the prerelease components are based on: - A `NumericIdentifier` class, that compares number using their natural order, and always compares lower than non-numeric identifiers - A `AlphaIdentifier` class for non-numeric identifiers; it compares versions using ASCII ordering. - A `MaxIdentifier` class, that compares higher to any other identifier; used to ensure that a non-prerelease version is greater than any of its prereleases.
* Add some docstrings.Raphaël Barrois2019-08-261-0/+1
|
* Add deprecations for Spec/SpecItem.Raphaël Barrois2019-08-261-13/+42
| | | | | | | | | The internal features from those classes will be removed in future versions: - The `Spec` class is incompatible with the support of multiple syntaxes - The `SpecItem` class was an implementation detail, but doesn't support complex `Range` combinations.
* Add support for NPM-style version ranges.Raphaël Barrois2019-08-261-0/+194
| | | | | | | | The code follows closely the specification available at https://docs.npmjs.com/misc/semver.html. Despite similarities, the matching logic is fully separate from the `native` code, since both might evolve at their own scales.
* Refactor spec/version matching.Raphaël Barrois2019-08-261-65/+568
| | | | | | | | | | | | | | | | | | | | | | | Instead of choosing the comparison on each `.match()` call, the expression is converted to a combination of `Range()` expressions (simple comparison to a semver-compliant `Version`). `Range()` objects can be combined with `And` and `Or` through the `AnyOf` and `AllOf` clauses (sticking to Python's naming scheme). Some specific flags have been provided to those range, allowing users to subtly alter the matching behaviour - thus accomodating different versioning schemes: - `<0.1.2` won't match `0.1.2-rc1`, unless the prerelease_policy flag is set to either `always` or `same-patch` - `<0.1.2` will match `0.1.1-rc1`, unless the `prerelease_policy` flag is set to `same-patch` - `==0.1.2` will always match `0.1.2+build44`, unless the `build_policy` is set to `strict`. The `Spec` item has been updated, alongside `SpecItem`. Those objects keep the original expression as attributes, but don't use them for comparisons.
* Fix inconsistent matching behaviour.Raphaël Barrois2019-08-241-1/+5
| | | | | | | | According to the stated goal of "intuitive" behaviour, we want: ``Version('0.1.1-a1') not in Spec('<0.1.1')``. Tests, code and docs have been fixed.
* Add `Version.truncate()`.Raphaël Barrois2019-08-241-0/+36
| | | | This simplifies computing neighbouring versions.
* Clarify hashing strategy for Version.Raphaël Barrois2019-08-241-0/+2
|
* Drop support for Python<3.4.Raphaël Barrois2019-08-241-10/+15
|
* Use Version(major=1, ...) for next_...Raphaël Barrois2019-08-241-7/+35
| | | | Avoids generating text to be parsed immediately.
* Allow Version(major=1, ...).Raphaël Barrois2019-08-241-2/+43
| | | | | | Eases the creation of version objects from existing versions. We still validate the type and structure of each component.
* Make class name dynamic in Version.__repr__Kyle Baird2018-06-181-1/+2
| | | | | Do this so any subclasses will be shown with their class name instead of a potentially misleading Version
* Don't use `is` for integer comparisons.Raphaël Barrois2018-06-181-2/+2
| | | | | | Closes #65. Reported-By: Julian Berman <julian@grayvines.com>
* correct spelling mistakeEdward Betts2017-09-031-1/+1
|
* LintingRaphaël Barrois2016-09-011-7/+14
|
* Fix a bug with compatible release clauses and patch versionsMartin Ek2016-03-071-1/+1
| | | | | Previously, if the patch version was 0 (i.e. as in ~=2.2.0), this would cause the range to be interpreted as ~=2.2.
* Add support for compatible release ranges, fixes #37Martin Ek2016-02-251-1/+8
|
* Fix handling pre-1.0.0 caret versions (Closes #35)Raphaël Barrois2016-02-211-1/+7
| | | | Thanks to @autopulated for pointing the issue!
* lint: Remove double return.Raphaël Barrois2016-02-211-1/+0
|
* Cleanup and document fixes from #31.Raphaël Barrois2016-02-121-12/+14
| | | | The PR was broken through fixed in ``next_minor()`` / ``next_major()``.
* Merge branch 'tilde-caret' of ↵Raphaël Barrois2016-02-121-2/+18
|\ | | | | | | https://github.com/skwashd/python-semanticversion into skwashd-tilde-caret
| * Support for alternative equals specsDave Hall2015-11-291-2/+4
| | | | | | | | | | Composer assumes equals if no operator is used npm uses a single equals operator
| * Make regex more readableDave Hall2015-10-191-2/+1
| |
| * Add support for npm/composer caret and tilde condition extensionsDave Hall2015-10-151-1/+16
| |
* | Remove Copyright years (Closes #28)Raphaël Barrois2016-02-121-1/+1
| | | | | | | | It seems that stating the copyright years is useless after all :)
* | Merge branch 'bump-version-2' of ↵Raphaël Barrois2016-02-121-5/+14
|\ \ | |/ |/| | | https://github.com/MinchinWeb/python-semanticversion into MinchinWeb-bump-version-2
| * Adjust code to match tests for bumping prerelease versionsMinchinWeb2015-09-151-5/+14
| |
* | Forbid build metadata ordering (See #18)Raphaël Barrois2015-09-151-37/+36
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | SemVer 2.0.0 states that "Build metadata SHOULD be ignored when determining version precedence". This means that, when comparing ``0.1.0+1`` to ``0.1.0+bcd``:: >>> Version('0.1.0+1') == Version('0.1.0+bcd') False >>> Version('0.1.0+1') != Version('0.1.0+bcd') True >>> Version('0.1.0+1') < Version('0.1.0+bcd') False >>> Version('0.1.0+1') > Version('0.1.0+bcd') False >>> Version('0.1.0+1') <= Version('0.1.0+bcd') False >>> Version('0.1.0+1') >= Version('0.1.0+bcd') False >>> compare(Version('0.1.0+1'), Version('0.1.0+bcd')) NotImplemented This change also has the following effects: - When including build metadata in a ``Spec``, the only valid options are ``Spec('==0.1.0+sth')`` and ``Spec('!=0.1.0+sth')`` - The meaning of ``Spec('==0.1.0+')`` is now "Only version 0.1.0 without build metadata" - ``Spec('==0.1.0')`` now matches ``Version('0.1.0+anything')``
* Adds a new bump version func to the API.Rick Eyre2015-04-011-0/+11
|
* Fix unescaped regexps (Closes #12).Raphaël Barrois2015-04-011-2/+2
|
* Accept '*' as a Spec (Closes #8).Raphaël Barrois2014-03-161-10/+8
| | | | Spec('*') will match all valid Version objects.
* Update copyrightRaphaël Barrois2014-03-081-1/+1
|
* Upgrade to semver-2.0.0 (Closes #3)Raphaël Barrois2014-02-131-0/+24
|
* Normalize docs to docs/ (Closes #5).Raphaël Barrois2013-12-231-0/+490
Also normalize the package layout. Thanks @jdowner-gb & tleach for the report.