├── awesomeversion ├── py.typed ├── utils │ ├── __init__.py │ ├── validate.py │ └── regex.py ├── comparehandlers │ ├── __init__.py │ ├── simple.py │ ├── container.py │ ├── sections.py │ └── modifier.py ├── exceptions.py ├── typing.py ├── __init__.py └── strategy.py ├── tests ├── utils │ ├── __init__.py │ └── test_validate.py ├── __init__.py ├── issues │ ├── test_issue26.py │ ├── test_issue14.py │ ├── test_issue333.py │ ├── test_issue153.py │ ├── test_issue96.py │ └── test_issue422.py ├── snapshots │ ├── BuildVer │ │ ├── 0.json │ │ ├── 1.json │ │ ├── 2.json │ │ ├── 123.json │ │ ├── 2019.json │ │ ├── 2020.json │ │ ├── 01234567.json │ │ └── 16785665.json │ ├── CalVer │ │ ├── 20.1.json │ │ ├── 20.1.0.json │ │ ├── 2020.1.1..json │ │ ├── 2020.1.json │ │ ├── 2020.2.0.json │ │ ├── 2021.1.0.json │ │ ├── 2021.2.0.json │ │ ├── 2020.12.0.json │ │ ├── 2020.12.1.json │ │ ├── 2020.21.1.json │ │ ├── 2021.1.0.0.json │ │ ├── 2021.1.0a0.json │ │ ├── 2021.1.0b0.json │ │ ├── 2021.1.0b1.json │ │ ├── 2021.1.0b2.json │ │ ├── 2021.2.0b0.json │ │ ├── 2021.2.0b10.json │ │ ├── 2022.01.01.json │ │ ├── 2022.01.02.json │ │ ├── 2022.02.01.json │ │ ├── 2022.02.02.json │ │ ├── 2022.03.01.json │ │ ├── 2022.03.02.json │ │ ├── 2023.01.01.json │ │ ├── 2023.01.02.json │ │ ├── 2023.02.01.json │ │ ├── 2023.02.02.json │ │ ├── 2023.03.01.json │ │ ├── 2023.03.02.json │ │ ├── 2021.1.0dev0.json │ │ ├── 2021.1.0.dev0.json │ │ ├── 2020.12.dev1602.json │ │ ├── 2020.12.dev1603.json │ │ ├── 2021.1.0dev20210101.json │ │ └── 2021.2.0.dev20210118.json │ ├── HexVer │ │ ├── 0x0.json │ │ ├── 0x2df35.json │ │ ├── 0x00AABB00.json │ │ ├── 0x01002100.json │ │ └── 0x23089631.json │ ├── PEP 440 │ │ ├── 1.0a1.json │ │ ├── 1.0b0.json │ │ ├── 1.0b1.json │ │ ├── 1.0b2.json │ │ ├── 1.2b0.json │ │ ├── 1.0.0b0.json │ │ ├── 1.0.0b1.json │ │ ├── 1.0.0b10.json │ │ ├── 1.0.0b9.json │ │ ├── 1.0.a0.json │ │ ├── 1.0.b0.json │ │ ├── 1.0.b1.json │ │ ├── 1.0.b2.json │ │ ├── 1.0.d1.json │ │ ├── 1.0a12.json │ │ ├── 1.0rc1.json │ │ ├── 1_dev1.json │ │ ├── 1-dev1.json │ │ ├── 1.0.0rc0.json │ │ ├── 1.0.dev0.json │ │ ├── 1.0.dev1.json │ │ ├── 1.0.rc2.json │ │ ├── 1.1-dev1.json │ │ ├── 1.1.dev1.json │ │ ├── 1.1_dev1.json │ │ ├── 1.2.3.4.5b0.json │ │ ├── 1.dev0.json │ │ ├── 1.dev1.json │ │ ├── 6.0.rc1.json │ │ ├── 1.0.0beta0.json │ │ ├── 1.0+local.1.2.3.json │ │ ├── 1.0.alpha1.json │ │ ├── 1.0.dev456.json │ │ ├── 1.0a2.dev456.json │ │ ├── 1.0b1.dev456.json │ │ ├── 1.0.post456.json │ │ ├── 1.0a12.dev456.json │ │ ├── 1.0b2.post345.json │ │ ├── 1.0rc1+local.1.2.3.json │ │ ├── 1.0rc1.dev456.json │ │ ├── 1.0.post456.dev34.json │ │ ├── 6.0.dev20210429.json │ │ └── 1.0b2.post345.dev456.json │ ├── SemVer │ │ ├── 1.0.0.json │ │ ├── 1.0.1.json │ │ ├── 1.2.3.json │ │ ├── 2.0.0.json │ │ ├── 2.1.0.json │ │ ├── 2.1.1.json │ │ ├── 2.1.3.json │ │ ├── 3.0.0.json │ │ ├── 3.0.1.json │ │ ├── 4.0.0.json │ │ ├── 4.1.0.json │ │ ├── 4.2.0.json │ │ ├── 5.0.0.json │ │ ├── 5.1.0.json │ │ ├── 5.1.1.json │ │ ├── 6.0.0.json │ │ ├── 6.1.0.json │ │ ├── 6.2.0.json │ │ ├── 7.0.0.json │ │ ├── 7.1.0.json │ │ ├── 7.1.1.json │ │ ├── v1.0.1.json │ │ ├── v1.1.1.json │ │ ├── v1.2.1.json │ │ ├── v2.0.1.json │ │ ├── v2.1.1.json │ │ ├── v2.2.1.json │ │ ├── 0.118.0.json │ │ ├── 1.2.3-1.json │ │ ├── 1.2.3-2.json │ │ ├── 2.4.6-8.json │ │ ├── 1.0.0-beta.json │ │ ├── 1.0.0-rc.1.json │ │ ├── 1.0.0-rc.2.json │ │ ├── 1.0.0-rc0.json │ │ ├── 2.0.0-rc.1.json │ │ ├── 2.0.0-rc.2.json │ │ ├── 3.0.0-rc.1.json │ │ ├── 3.0.0-rc.2.json │ │ ├── 1.0.0-alpha.json │ │ ├── 1.0.0-beta0.json │ │ ├── 1.0.0-beta1.json │ │ ├── 1.2.3-dev.1.json │ │ ├── 1.0.0-alpha1.json │ │ ├── 1.0.0-alpha9.json │ │ ├── 1.0.0-beta.1.json │ │ ├── 1.0.0-beta.10.json │ │ ├── 1.0.0-beta.2.json │ │ ├── 1.0.0-beta.9.json │ │ ├── 2.0.0-beta.1.json │ │ ├── 2.0.0-beta.2.json │ │ ├── 3.0.0-beta.1.json │ │ ├── 3.0.0-beta.2.json │ │ ├── 1.0.0-alpha+1.2.json │ │ ├── 1.0.0-alpha.1.json │ │ ├── 1.0.0-alpha.2.json │ │ ├── 1.0.0-alpha10.json │ │ ├── 1.2.3-alpha.1.json │ │ ├── 1.8.2-beta.1.10.json │ │ ├── 1.8.2-beta.1.13.json │ │ ├── 2.0.0-alpha.1.json │ │ ├── 2.0.0-alpha.2.json │ │ ├── 3.0.0-alpha.1.json │ │ ├── 3.0.0-alpha.2.json │ │ └── 1.8.2-beta.1.10+somebuild.json │ ├── unknown │ │ ├── .json │ │ ├── 0x0g.json │ │ ├── None.json │ │ ├── True.json │ │ ├── a.b.c.json │ │ ├── False.json │ │ ├── 00AABB00.json │ │ ├── 0X01002604.json │ │ ├── unknown.json │ │ ├── .json │ │ ├── 1.0.invalid4.json │ │ └── .json │ ├── SimpleVer │ │ ├── 0.1.json │ │ ├── 1.0.json │ │ ├── 1.1.json │ │ ├── 5.10.json │ │ ├── 5.11.json │ │ ├── 6.0.json │ │ ├── v1.0.json │ │ ├── v1.1.json │ │ ├── v1.2.json │ │ ├── v2.0.json │ │ ├── v2.1.json │ │ ├── v2.2.json │ │ ├── 1.2.3.4.json │ │ ├── 1.2.3.4.5.json │ │ ├── 1.2.3.4.5.6.6.8.json │ │ ├── 1.2.3.4.5.6.7.8.json │ │ └── 1.2.3.4.5.6.7.8.9.json │ └── SpecialContainer │ │ ├── beta.json │ │ ├── dev.json │ │ ├── latest.json │ │ └── stable.json ├── test_equals.py ├── test_coverage_edge_cases.py ├── test_snapshots.py ├── test_version_scheme.py ├── test_strategy.py ├── test_versions.py ├── test_compare.py └── test_handlers.py ├── .gitattributes ├── benchmarks ├── __init__.py ├── const.py ├── test_constructor.py ├── test_properties.py ├── test_compare.py ├── test_strategy.py ├── test_collections.py ├── test_operations.py └── test_edge_cases.py ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.yml │ └── bug.yml ├── release.yml ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── codspeed.yml │ ├── release.yml │ └── actions.yml ├── renovate.json ├── .gitignore ├── script ├── update ├── build ├── setup ├── benchmark ├── snapshot-update ├── coverage ├── bootstrap ├── lint ├── lint-check ├── motd ├── test ├── set-version └── help ├── .codecov.yml ├── LICENCE.md ├── .devcontainer.json ├── pyproject.toml └── README.md /awesomeversion/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf -------------------------------------------------------------------------------- /awesomeversion/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Initialize tests.""" 2 | -------------------------------------------------------------------------------- /benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | """Init benchmarks package.""" 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /benchmarks/const.py: -------------------------------------------------------------------------------- 1 | """Benchmark constants.""" 2 | 3 | DEFAULT_RUNS = 1_000 4 | -------------------------------------------------------------------------------- /awesomeversion/comparehandlers/__init__.py: -------------------------------------------------------------------------------- 1 | """Initialize the comparehandlers for AwesomeVersion.""" 2 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | labels: 4 | - demo 5 | - dependencies 6 | - repository 7 | - test 8 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | __target__ 3 | .codspeed 4 | .mypy_cache 5 | .pytest_cache 6 | .coverage 7 | coverage.xml 8 | dist 9 | build/ 10 | *.egg-info -------------------------------------------------------------------------------- /script/update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/update: Update project after a fresh pull 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | script/bootstrap 10 | 11 | echo "==> Update completed!" 12 | -------------------------------------------------------------------------------- /script/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/build: Build the package. 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | echo "==> Building package..." 10 | uv build 11 | 12 | echo "==> Build completed!" 13 | -------------------------------------------------------------------------------- /script/setup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/setup: Set up project for first-time use after cloning 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | script/bootstrap 10 | 11 | echo "==> App is now ready to go!" 12 | -------------------------------------------------------------------------------- /awesomeversion/utils/validate.py: -------------------------------------------------------------------------------- 1 | """Utils to validate.""" 2 | 3 | 4 | def value_is_base16(value: str) -> bool: 5 | """Check if a value is base16.""" 6 | try: 7 | int(value, 16) 8 | except ValueError: 9 | return False 10 | return True 11 | -------------------------------------------------------------------------------- /script/benchmark: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/benchmark: Run performance benchmarks 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | echo "==> Running benchmarks..." 10 | uv run --dev pytest -x --no-cov -vvvvv benchmarks 11 | 12 | echo "==> Benchmarks completed!" 13 | -------------------------------------------------------------------------------- /script/snapshot-update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/snapshot-update: Update test snapshot files. 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | echo "==> Updating test snapshots..." 10 | uv run --dev pytest tests --snapshot-update --timeout=10 11 | 12 | echo "==> Snapshot update completed!" 13 | -------------------------------------------------------------------------------- /tests/issues/test_issue26.py: -------------------------------------------------------------------------------- 1 | """Test for issue #26.""" 2 | 3 | # https://github.com/ludeeus/awesomeversion/issues/26 4 | from awesomeversion import AwesomeVersion 5 | 6 | 7 | def test() -> None: 8 | """Test for issue #26.""" 9 | current = AwesomeVersion(" 123") 10 | upstream = AwesomeVersion("123") 11 | assert current == upstream 12 | -------------------------------------------------------------------------------- /script/coverage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/coverage: Run tests and generate coverage reports 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | echo "==> Running coverage analysis..." 10 | uv run --dev pytest tests --timeout=10 -rxf -x -v -l --cov=./ --cov-report=xml > /dev/null 11 | uv run --dev coverage report 12 | 13 | echo "==> Coverage analysis completed!" 14 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | codecov: 3 | branch: main 4 | 5 | coverage: 6 | precision: 2 7 | status: 8 | patch: off 9 | project: 10 | default: 11 | target: 100% 12 | 13 | parsers: 14 | gcov: 15 | branch_detection: 16 | conditional: yes 17 | loop: yes 18 | method: no 19 | macro: no 20 | 21 | ignore: 22 | - "tests" -------------------------------------------------------------------------------- /awesomeversion/exceptions.py: -------------------------------------------------------------------------------- 1 | """Exceptions for AwesomeVersion.""" 2 | 3 | 4 | class AwesomeVersionException(Exception): 5 | """Base AwesomeVersion exception.""" 6 | 7 | 8 | class AwesomeVersionCompareException(AwesomeVersionException): 9 | """Thrown when compare is not possible.""" 10 | 11 | 12 | class AwesomeVersionStrategyException(AwesomeVersionException): 13 | """Thrown when the expected strategy does not match.""" 14 | -------------------------------------------------------------------------------- /tests/issues/test_issue14.py: -------------------------------------------------------------------------------- 1 | """Test for issue #14.""" 2 | 3 | # https://github.com/ludeeus/awesomeversion/issues/14 4 | from awesomeversion import AwesomeVersion 5 | from awesomeversion.strategy import AwesomeVersionStrategy 6 | 7 | 8 | def test() -> None: 9 | """Test for issue #14.""" 10 | version = AwesomeVersion("2021.1.0.dev20201230") 11 | assert version.dev 12 | assert version.strategy != AwesomeVersionStrategy.UNKNOWN 13 | -------------------------------------------------------------------------------- /script/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/bootstrap: Install/update all dependencies required to run the project 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | echo "==> Installing uv if not present..." 10 | if ! command -v uv >/dev/null 2>&1; then 11 | echo "UV not found, re-build the devcontainer..." 12 | exit 1 13 | fi 14 | 15 | echo "==> Installing dependencies..." 16 | uv sync --dev --all-extras 17 | 18 | echo "==> Bootstrap completed!" 19 | -------------------------------------------------------------------------------- /tests/snapshots/BuildVer/0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "0", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "BuildVer", 16 | "string": "0", 17 | "valid": true, 18 | "year": "0" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/BuildVer/1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "BuildVer", 16 | "string": "1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/BuildVer/2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "BuildVer", 16 | "string": "2", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/20.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "20", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "20.1", 17 | "valid": true, 18 | "year": "20" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/HexVer/0x0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "HexVer", 16 | "string": "0x0", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0a1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "a", 9 | "modifier": "a1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0a1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0b0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b0", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0b0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0b1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0b1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0b2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b2", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0b2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.2b0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "2", 8 | "modifier_type": "b", 9 | "modifier": "b0", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.2b0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "1.0.0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "1", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "1.0.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.2.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "1.2.3", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "2.0.0", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "2.1.0", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.1.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "1", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "2.1.1", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.1.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "3", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "2.1.3", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/3.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "3", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "3.0.0", 17 | "valid": true, 18 | "year": "3" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/3.0.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "3", 6 | "micro": "1", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "3.0.1", 17 | "valid": true, 18 | "year": "3" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/4.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "4", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "4.0.0", 17 | "valid": true, 18 | "year": "4" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/4.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "4", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "4.1.0", 17 | "valid": true, 18 | "year": "4" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/4.2.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "4", 6 | "micro": "0", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "4.2.0", 17 | "valid": true, 18 | "year": "4" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/5.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "5", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "5.0.0", 17 | "valid": true, 18 | "year": "5" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/5.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "5", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "5.1.0", 17 | "valid": true, 18 | "year": "5" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/5.1.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "5", 6 | "micro": "1", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "5.1.1", 17 | "valid": true, 18 | "year": "5" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/6.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "6", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "6.0.0", 17 | "valid": true, 18 | "year": "6" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/6.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "6", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "6.1.0", 17 | "valid": true, 18 | "year": "6" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/6.2.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "6", 6 | "micro": "0", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "6.2.0", 17 | "valid": true, 18 | "year": "6" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/7.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "7", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "7.0.0", 17 | "valid": true, 18 | "year": "7" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/7.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "7", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "7.1.0", 17 | "valid": true, 18 | "year": "7" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/7.1.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "7", 6 | "micro": "1", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "7.1.1", 17 | "valid": true, 18 | "year": "7" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/v1.0.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "1", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "1.0.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/v1.1.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "1", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "1.1.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/v1.2.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "1", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "1.2.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/v2.0.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "1", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "2.0.1", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/v2.1.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "1", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "2.1.1", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/v2.2.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "1", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "2.2.1", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 0, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/BuildVer/123.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "123", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "BuildVer", 16 | "string": "123", 17 | "valid": true, 18 | "year": "123" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/20.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "20", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "20.1.0", 17 | "valid": true, 18 | "year": "20" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.0b0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.0b0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.0b1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.0b1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.0b10.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b10", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.0b10", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.0b9.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b9", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.0b9", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.a0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "a", 9 | "modifier": "a0", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.a0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.b0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b0", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.b0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.b1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.b1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.b2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "b", 9 | "modifier": "b2", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.b2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.d1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "d", 9 | "modifier": "d1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.d1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0a12.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "a", 9 | "modifier": "a12", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0a12", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0rc1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0rc1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1_dev1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1_dev1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/0.118.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "0", 6 | "micro": "0", 7 | "minor": "118", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "SemVer", 16 | "string": "0.118.0", 17 | "valid": true, 18 | "year": "0" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.2.3-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": "1", 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.2.3-1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.2.3-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": "2", 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.2.3-2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.4.6-8.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "6", 7 | "minor": "4", 8 | "modifier_type": null, 9 | "modifier": "8", 10 | "patch": "6", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "2.4.6-8", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/0.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "0", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "0.1", 17 | "valid": true, 18 | "year": "0" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/1.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/5.10.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "5", 6 | "micro": null, 7 | "minor": "10", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "5.10", 17 | "valid": true, 18 | "year": "5" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/5.11.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "5", 6 | "micro": null, 7 | "minor": "11", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "5.11", 17 | "valid": true, 18 | "year": "5" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/6.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "6", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "6.0", 17 | "valid": true, 18 | "year": "6" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/v1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/v1.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/v1.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/v2.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "2.0", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/v2.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "2.1", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/v2.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": null, 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": "v", 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "2.2", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/0x0g.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "0x0g", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/None.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "None", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/True.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "True", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/a.b.c.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": "c", 9 | "modifier": "c", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "a.b.c", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/BuildVer/2019.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2019", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "BuildVer", 16 | "string": "2019", 17 | "valid": true, 18 | "year": "2019" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/BuildVer/2020.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2020", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "BuildVer", 16 | "string": "2020", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2020.1.1..json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2020", 6 | "micro": "1", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2020.1.1", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2020.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2020", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2020.1", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2020.2.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2020", 6 | "micro": "0", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2020.2.0", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.2.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2021.2.0", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/HexVer/0x2df35.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "HexVer", 16 | "string": "0x2df35", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1-dev1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": "dev", 9 | "modifier": "dev1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1-dev1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.0rc0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.0rc0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.dev0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev0", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.dev0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.dev1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.dev1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.rc2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc2", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.rc2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.1-dev1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": "dev", 9 | "modifier": "dev1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.1-dev1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.1.dev1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": "dev", 9 | "modifier": "dev1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.1.dev1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.1_dev1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.1_dev1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.2.3.4.5b0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": "b", 9 | "modifier": "b0", 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 5, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.2.3.4.5b0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.dev0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": "dev", 9 | "modifier": "dev0", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.dev0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.dev1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": "dev", 9 | "modifier": "dev1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.dev1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/6.0.rc1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "6", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "6.0.rc1", 17 | "valid": true, 18 | "year": "6" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-beta.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-beta", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-rc.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-rc.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-rc.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-rc.2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-rc0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-rc0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.0.0-rc.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "2.0.0-rc.1", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.0.0-rc.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "2.0.0-rc.2", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/3.0.0-rc.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "3", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "3.0.0-rc.1", 17 | "valid": true, 18 | "year": "3" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/3.0.0-rc.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "3", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "rc", 9 | "modifier": "rc.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "3.0.0-rc.2", 17 | "valid": true, 18 | "year": "3" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/1.2.3.4.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 4, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.2.3.4", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/False.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "False", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2020.12.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2020", 6 | "micro": "0", 7 | "minor": "12", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2020.12.0", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2020.12.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2020", 6 | "micro": "1", 7 | "minor": "12", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2020.12.1", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2020.21.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2020", 6 | "micro": "1", 7 | "minor": "21", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2020.21.1", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 4, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0.0", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0a0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": "a", 9 | "modifier": "a0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0a0", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0b0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": "b", 9 | "modifier": "b0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0b0", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0b1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": "b", 9 | "modifier": "b1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0b1", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0b2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": "b", 9 | "modifier": "b2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0b2", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.2.0b0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "2", 8 | "modifier_type": "b", 9 | "modifier": "b0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.2.0b0", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.2.0b10.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "2", 8 | "modifier_type": "b", 9 | "modifier": "b10", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.2.0b10", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2022.01.01.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2022", 6 | "micro": "1", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2022.01.01", 17 | "valid": true, 18 | "year": "2022" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2022.01.02.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2022", 6 | "micro": "2", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2022.01.02", 17 | "valid": true, 18 | "year": "2022" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2022.02.01.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2022", 6 | "micro": "1", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2022.02.01", 17 | "valid": true, 18 | "year": "2022" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2022.02.02.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2022", 6 | "micro": "2", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2022.02.02", 17 | "valid": true, 18 | "year": "2022" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2022.03.01.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2022", 6 | "micro": "1", 7 | "minor": "3", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2022.03.01", 17 | "valid": true, 18 | "year": "2022" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2022.03.02.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2022", 6 | "micro": "2", 7 | "minor": "3", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2022.03.02", 17 | "valid": true, 18 | "year": "2022" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2023.01.01.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2023", 6 | "micro": "1", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2023.01.01", 17 | "valid": true, 18 | "year": "2023" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2023.01.02.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2023", 6 | "micro": "2", 7 | "minor": "1", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2023.01.02", 17 | "valid": true, 18 | "year": "2023" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2023.02.01.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2023", 6 | "micro": "1", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2023.02.01", 17 | "valid": true, 18 | "year": "2023" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2023.02.02.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2023", 6 | "micro": "2", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2023.02.02", 17 | "valid": true, 18 | "year": "2023" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2023.03.01.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2023", 6 | "micro": "1", 7 | "minor": "3", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2023.03.01", 17 | "valid": true, 18 | "year": "2023" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2023.03.02.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2023", 6 | "micro": "2", 7 | "minor": "3", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": true, 15 | "strategy": "CalVer", 16 | "string": "2023.03.02", 17 | "valid": true, 18 | "year": "2023" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/HexVer/0x00AABB00.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "HexVer", 16 | "string": "0x00AABB00", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/HexVer/0x01002100.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "HexVer", 16 | "string": "0x01002100", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/HexVer/0x23089631.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "HexVer", 16 | "string": "0x23089631", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.0beta0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.0beta0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-alpha.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-alpha", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-beta0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-beta0", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-beta1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-beta1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.2.3-dev.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": "dev", 9 | "modifier": "dev.1", 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.2.3-dev.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/1.2.3.4.5.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 5, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.2.3.4.5", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/00AABB00.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "00AABB00", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0dev0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": "dev", 9 | "modifier": "dev0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0dev0", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0+local.1.2.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "1", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 5, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0+local.1.2.3", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.alpha1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha1", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.alpha1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.dev456.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev456", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.dev456", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0a2.dev456.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev456", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0a2.dev456", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0b1.dev456.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev456", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0b1.dev456", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-alpha1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-alpha1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-alpha9.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha9", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-alpha9", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-beta.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-beta.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-beta.10.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta.10", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-beta.10", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-beta.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-beta.2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-beta.9.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta.9", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-beta.9", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.0.0-beta.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "2.0.0-beta.1", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.0.0-beta.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "2.0.0-beta.2", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/3.0.0-beta.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "3", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "3.0.0-beta.1", 17 | "valid": true, 18 | "year": "3" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/3.0.0-beta.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "3", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "beta", 9 | "modifier": "beta.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "3.0.0-beta.2", 17 | "valid": true, 18 | "year": "3" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SpecialContainer/beta.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": true, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "SpecialContainer", 16 | "string": "beta", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SpecialContainer/dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "SpecialContainer", 16 | "string": "dev", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/0X01002604.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "0X01002604", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/unknown.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": "unknown", 9 | "modifier": "unknown", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 0, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "unknown", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/issues/test_issue333.py: -------------------------------------------------------------------------------- 1 | """Test for issue #333.""" 2 | 3 | # https://github.com/ludeeus/awesomeversion/issues/333 4 | from awesomeversion import AwesomeVersion 5 | from awesomeversion.strategy import AwesomeVersionStrategy 6 | 7 | 8 | def test() -> None: 9 | """Test for issue #333.""" 10 | version = AwesomeVersion("v3.4-rc5") 11 | assert version < "v3.6-rc2" 12 | assert version.release_candidate 13 | assert version.strategy != AwesomeVersionStrategy.UNKNOWN 14 | -------------------------------------------------------------------------------- /tests/snapshots/BuildVer/01234567.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1234567", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "BuildVer", 16 | "string": "01234567", 17 | "valid": true, 18 | "year": "1234567" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/BuildVer/16785665.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "16785665", 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "BuildVer", 16 | "string": "16785665", 17 | "valid": true, 18 | "year": "16785665" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0.dev0.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": "dev", 9 | "modifier": "dev0", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0.dev0", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.post456.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "post", 9 | "modifier": "post456", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.post456", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0a12.dev456.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev456", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0a12.dev456", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0b2.post345.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "post", 9 | "modifier": "post345", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0b2.post345", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0rc1+local.1.2.3.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "1", 7 | "minor": "0", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "1", 11 | "prefix": null, 12 | "release_candidate": true, 13 | "sections": 5, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0rc1+local.1.2.3", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0rc1.dev456.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev456", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0rc1.dev456", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-alpha+1.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-alpha+1.2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-alpha.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-alpha.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-alpha.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-alpha.2", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.0.0-alpha10.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha10", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.0.0-alpha10", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.2.3-alpha.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha.1", 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.2.3-alpha.1", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.8.2-beta.1.10.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "2", 7 | "minor": "8", 8 | "modifier_type": null, 9 | "modifier": "beta.1.10", 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.8.2-beta.1.10", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.8.2-beta.1.13.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "2", 7 | "minor": "8", 8 | "modifier_type": null, 9 | "modifier": "beta.1.13", 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.8.2-beta.1.13", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.0.0-alpha.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "2.0.0-alpha.1", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/2.0.0-alpha.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "2", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "2.0.0-alpha.2", 17 | "valid": true, 18 | "year": "2" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/3.0.0-alpha.1.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "3", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha.1", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "3.0.0-alpha.1", 17 | "valid": true, 18 | "year": "3" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/3.0.0-alpha.2.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": false, 5 | "major": "3", 6 | "micro": "0", 7 | "minor": "0", 8 | "modifier_type": "alpha", 9 | "modifier": "alpha.2", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "3.0.0-alpha.2", 17 | "valid": true, 18 | "year": "3" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/1.2.3.4.5.6.6.8.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 8, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.2.3.4.5.6.6.8", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/1.2.3.4.5.6.7.8.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 8, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.2.3.4.5.6.7.8", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SpecialContainer/latest.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "SpecialContainer", 16 | "string": "latest", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SpecialContainer/stable.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "SpecialContainer", 16 | "string": "stable", 17 | "valid": true, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/utils/test_validate.py: -------------------------------------------------------------------------------- 1 | """Tests for the validate util.""" 2 | 3 | import pytest 4 | 5 | from awesomeversion.utils.validate import value_is_base16 6 | 7 | 8 | @pytest.mark.parametrize( 9 | ("value", "expected"), 10 | ( 11 | ("0x0", True), 12 | ("0xah", False), 13 | ("0", True), 14 | ), 15 | ) 16 | def test_value_is_base16(value: str, expected: bool) -> None: 17 | """Test value is base16.""" 18 | assert value_is_base16(value) == expected 19 | -------------------------------------------------------------------------------- /tests/snapshots/SimpleVer/1.2.3.4.5.6.7.8.9.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "3", 7 | "minor": "2", 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": "3", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 9, 14 | "simple": true, 15 | "strategy": "SimpleVer", 16 | "string": "1.2.3.4.5.6.7.8.9", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/1.0.invalid4.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": false, 4 | "dev": true, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": "invalid", 9 | "modifier": "invalid4", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "1.0.invalid4", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2020.12.dev1602.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "2020", 6 | "micro": null, 7 | "minor": "12", 8 | "modifier_type": "dev", 9 | "modifier": "dev1602", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2020.12.dev1602", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2020.12.dev1603.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "2020", 6 | "micro": null, 7 | "minor": "12", 8 | "modifier_type": "dev", 9 | "modifier": "dev1603", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2020.12.dev1603", 17 | "valid": true, 18 | "year": "2020" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0.post456.dev34.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": "456", 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev34", 10 | "patch": "456", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0.post456.dev34", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/6.0.dev20210429.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "6", 6 | "micro": null, 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev20210429", 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 2, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "6.0.dev20210429", 17 | "valid": true, 18 | "year": "6" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/PEP 440/1.0b2.post345.dev456.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "1", 6 | "micro": "345", 7 | "minor": "0", 8 | "modifier_type": "dev", 9 | "modifier": "dev456", 10 | "patch": "345", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "PEP 440", 16 | "string": "1.0b2.post345.dev456", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.1.0dev20210101.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "1", 8 | "modifier_type": "dev", 9 | "modifier": "dev20210101", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.1.0dev20210101", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/CalVer/2021.2.0.dev20210118.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": true, 5 | "major": "2021", 6 | "micro": "0", 7 | "minor": "2", 8 | "modifier_type": "dev", 9 | "modifier": "dev20210118", 10 | "patch": "0", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "CalVer", 16 | "string": "2021.2.0.dev20210118", 17 | "valid": true, 18 | "year": "2021" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/SemVer/1.8.2-beta.1.10+somebuild.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": true, 3 | "beta": true, 4 | "dev": false, 5 | "major": "1", 6 | "micro": "2", 7 | "minor": "8", 8 | "modifier_type": null, 9 | "modifier": "beta.1.10", 10 | "patch": "2", 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 3, 14 | "simple": false, 15 | "strategy": "SemVer", 16 | "string": "1.8.2-beta.1.10+somebuild", 17 | "valid": true, 18 | "year": "1" 19 | } -------------------------------------------------------------------------------- /tests/snapshots/unknown/.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": false, 3 | "beta": false, 4 | "dev": false, 5 | "major": null, 6 | "micro": null, 7 | "minor": null, 8 | "modifier_type": null, 9 | "modifier": null, 10 | "patch": null, 11 | "prefix": null, 12 | "release_candidate": false, 13 | "sections": 1, 14 | "simple": false, 15 | "strategy": "unknown", 16 | "string": "", 17 | "valid": false, 18 | "year": null 19 | } -------------------------------------------------------------------------------- /awesomeversion/typing.py: -------------------------------------------------------------------------------- 1 | """Custom types for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import TYPE_CHECKING, List, Tuple, Union 6 | 7 | from .strategy import AwesomeVersionStrategy 8 | 9 | if TYPE_CHECKING: 10 | from .awesomeversion import AwesomeVersion 11 | 12 | VersionType = Union[str, float, int, object, "AwesomeVersion"] 13 | EnsureStrategyIterableType = Union[ 14 | List[AwesomeVersionStrategy], Tuple[AwesomeVersionStrategy, ...] 15 | ] 16 | 17 | 18 | EnsureStrategyType = Union[AwesomeVersionStrategy, EnsureStrategyIterableType, None] 19 | -------------------------------------------------------------------------------- /awesomeversion/comparehandlers/simple.py: -------------------------------------------------------------------------------- 1 | """Special handler for simple.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import TYPE_CHECKING 6 | 7 | from .sections import compare_base_sections 8 | 9 | if TYPE_CHECKING: 10 | from awesomeversion import AwesomeVersion 11 | 12 | 13 | def compare_handler_simple( 14 | version_a: AwesomeVersion, 15 | version_b: AwesomeVersion, 16 | ) -> bool | None: 17 | """Compare handler simple.""" 18 | if version_a.simple and version_b.simple: 19 | return compare_base_sections(version_a, version_b) 20 | return None 21 | -------------------------------------------------------------------------------- /script/lint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/lint: Run linting tools and apply formatting 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | echo "==> Running linting tools..." 10 | 11 | echo "==> Running isort..." 12 | uv run --dev isort awesomeversion tests benchmarks 13 | 14 | echo "==> Running black..." 15 | uv run --dev black --fast awesomeversion tests benchmarks 16 | 17 | echo "==> Running mypy..." 18 | uv run --dev mypy --strict awesomeversion tests benchmarks 19 | 20 | echo "==> Running pylint..." 21 | uv run --dev pylint awesomeversion tests benchmarks 22 | 23 | echo "==> Linting completed!" 24 | -------------------------------------------------------------------------------- /awesomeversion/__init__.py: -------------------------------------------------------------------------------- 1 | """Initialize the AwesomeVersion package.""" 2 | 3 | from .awesomeversion import AwesomeVersion, AwesomeVersionDiff 4 | from .exceptions import ( 5 | AwesomeVersionCompareException, 6 | AwesomeVersionException, 7 | AwesomeVersionStrategyException, 8 | ) 9 | from .strategy import COMPARABLE_STRATEGIES, AwesomeVersionStrategy 10 | 11 | __all__ = [ 12 | "AwesomeVersion", 13 | "AwesomeVersionCompareException", 14 | "AwesomeVersionDiff", 15 | "AwesomeVersionException", 16 | "AwesomeVersionStrategy", 17 | "AwesomeVersionStrategyException", 18 | "COMPARABLE_STRATEGIES", 19 | ] 20 | -------------------------------------------------------------------------------- /script/lint-check: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/lint-check: Check linting without making changes. 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | echo "==> Checking linting..." 10 | 11 | echo "==> Checking isort..." 12 | uv run --dev isort awesomeversion tests benchmarks --check-only 13 | 14 | echo "==> Checking black..." 15 | uv run --dev black --check --fast awesomeversion tests benchmarks 16 | 17 | echo "==> Checking mypy..." 18 | uv run --dev mypy --strict awesomeversion tests benchmarks 19 | 20 | echo "==> Checking pylint..." 21 | uv run --dev pylint awesomeversion tests benchmarks 22 | 23 | echo "==> Linting check completed!" 24 | -------------------------------------------------------------------------------- /script/motd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/motd: Display Message of the Day for development environment 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | echo "" 10 | echo "🎉 Welcome to the AwesomeVersion development environment!" 11 | echo "" 12 | echo "📂 Project: $(pwd)" 13 | echo "🌿 Git branch: $(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'Not a git repo')" 14 | echo "🐍 Python: $(python3 --version 2>/dev/null || echo 'Not available')" 15 | if command -v uv >/dev/null 2>&1; then 16 | echo "📦 UV: $(uv --version)" 17 | else 18 | echo "📦 UV: Not installed" 19 | fi 20 | echo "" 21 | 22 | script/help 23 | 24 | echo "" 25 | echo "💡 Tip: Run './script/setup' if this is your first time, or './script/test' to run tests." 26 | echo "" 27 | -------------------------------------------------------------------------------- /script/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/test: Run test suite with optional file path argument 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | [ -z "$DEBUG" ] || set -x 10 | 11 | if [ "$CI" = "true" ]; then 12 | # CI environment - don't update, assume dependencies are already installed 13 | echo "==> Running tests in CI environment..." 14 | else 15 | # Development environment - ensure everything is up to date 16 | script/update 17 | fi 18 | 19 | echo "==> Running tests..." 20 | if [ -n "$1" ]; then 21 | # Run specific test file if provided 22 | uv run --dev pytest --timeout=10 "$1" -rxf -x -vv -l -s --cov=./ --cov-report=xml 23 | else 24 | # Run all tests 25 | uv run --dev pytest --timeout=10 tests -rxf -x -vv -l -s --cov=./ --cov-report=xml 26 | fi 27 | -------------------------------------------------------------------------------- /tests/test_equals.py: -------------------------------------------------------------------------------- 1 | """Test equals.""" 2 | 3 | import pytest 4 | 5 | from awesomeversion import AwesomeVersion 6 | from awesomeversion.typing import VersionType 7 | 8 | 9 | @pytest.mark.parametrize( 10 | "version", 11 | [ 12 | ("1"), 13 | ("2020.12.1"), 14 | ("2020"), 15 | ("2021.2.0b0"), 16 | ("2021.2.0.dev20210118"), 17 | ], 18 | ) 19 | def test_equals(version: VersionType) -> None: 20 | """Test equals.""" 21 | version_object = AwesomeVersion(version) 22 | assert version_object == version 23 | assert str(version_object) == version 24 | assert version_object.string == version 25 | assert version_object == AwesomeVersion(f"v{version}") 26 | assert version_object == AwesomeVersion(f"V{version}") 27 | -------------------------------------------------------------------------------- /tests/issues/test_issue153.py: -------------------------------------------------------------------------------- 1 | """Test for issue #153.""" 2 | 3 | # https://github.com/ludeeus/awesomeversion/issues/153 4 | from awesomeversion import AwesomeVersion 5 | 6 | 7 | def test() -> None: 8 | """Test for issue #153.""" 9 | current = AwesomeVersion("v1.10.0") 10 | 11 | dev1 = AwesomeVersion("v1.11.0-dev.1") 12 | dev2 = AwesomeVersion("v2.0.0-dev.1") 13 | dev3 = AwesomeVersion("v2.0.0-dev.2") 14 | 15 | assert current < dev1 16 | assert current < dev2 17 | assert current < dev3 18 | 19 | assert dev1 > current 20 | assert dev1 < dev2 21 | assert dev1 < dev3 22 | 23 | assert dev2 > current 24 | assert dev2 > dev1 25 | assert dev2 < dev3 26 | 27 | assert dev3 > current 28 | assert dev3 > dev1 29 | assert dev3 > dev2 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: "Feature request for AwesomeVersion" 2 | description: Suggest a feature/change to be added to AwesomeVersion 3 | labels: "enhancement" 4 | body: 5 | - type: textarea 6 | validations: 7 | required: true 8 | attributes: 9 | label: The idea 10 | description: > 11 | A good description of what you are suggesting. 12 | - type: textarea 13 | validations: 14 | required: true 15 | attributes: 16 | label: Implementation 17 | description: > 18 | How do you see this being implemented? 19 | - type: textarea 20 | attributes: 21 | label: Alternatives 22 | description: > 23 | Are there any alternative solutions or features you've considered? 24 | - type: textarea 25 | attributes: 26 | label: Additional context -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | ## What does this PR do? 6 | 7 | 8 | 9 | 10 | ## Type of change (pick one) 11 | 12 | - [ ] 🐛 Bug fix 13 | - [ ] ✨ New feature 14 | - [ ] 🔨 Code improvement or refactor 15 | - [ ] 📦 Dependency update 16 | - [ ] 💥 Breaking change 17 | 18 | ## Related issues or links 19 | 20 | 21 | 22 | 23 | ## Checklist 24 | 25 | - [ ] I tested my changes locally 26 | - [ ] All tests pass 27 | - [ ] No commented-out code left 28 | - [ ] Code is formatted (run `script/lint`) 29 | - [ ] Added or updated tests if needed 30 | 31 | -------------------------------------------------------------------------------- /script/set-version: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/set-version: Update the version in pyproject.toml 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | if [ -z "$1" ]; then 10 | echo "Error: Version argument is required" 11 | echo "Usage: script/set-version " 12 | echo "Example: script/set-version 1.2.3" 13 | exit 1 14 | fi 15 | 16 | VERSION="$1" 17 | 18 | echo "==> Updating version to $VERSION..." 19 | 20 | if [ -f "pyproject.toml" ]; then 21 | sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml 22 | echo "==> Updated pyproject.toml" 23 | else 24 | echo "Error: pyproject.toml not found" 25 | exit 1 26 | fi 27 | 28 | if grep -q "version = \"$VERSION\"" pyproject.toml; then 29 | echo "==> Version successfully updated to $VERSION" 30 | else 31 | echo "Error: Failed to update version" 32 | exit 1 33 | fi 34 | -------------------------------------------------------------------------------- /awesomeversion/comparehandlers/container.py: -------------------------------------------------------------------------------- 1 | """Special handler for container.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import TYPE_CHECKING 6 | 7 | from ..strategy import AwesomeVersionStrategy 8 | 9 | CONTAINER_VERSION_MAP = {"stable": 1, "beta": 2, "latest": 3, "dev": 4} 10 | 11 | if TYPE_CHECKING: 12 | from awesomeversion import AwesomeVersion 13 | 14 | 15 | def compare_handler_container( 16 | version_a: AwesomeVersion, 17 | version_b: AwesomeVersion, 18 | ) -> bool | None: 19 | """Compare handler container.""" 20 | if version_a.strategy == AwesomeVersionStrategy.SPECIALCONTAINER: 21 | if version_b.strategy != AwesomeVersionStrategy.SPECIALCONTAINER: 22 | return True 23 | return ( 24 | CONTAINER_VERSION_MAP[version_a.string] 25 | > CONTAINER_VERSION_MAP[version_b.string] 26 | ) 27 | if version_b.strategy == AwesomeVersionStrategy.SPECIALCONTAINER: 28 | return False 29 | return None 30 | -------------------------------------------------------------------------------- /script/help: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # script/help: Display information about available scripts. 4 | 5 | set -e 6 | 7 | cd "$(dirname "$0")/.." 8 | 9 | printf "\033[1m%s\033[36m %s\033[32m %s\033[0m \n\n" "Development environment for" "ludeeus/awesomeversion" "" 10 | 11 | echo "Available scripts:" 12 | echo "" 13 | 14 | for script in $(find script -type f -executable | sort); do 15 | script_name=$(basename "$script") 16 | description=$(awk -v prefix="# script/$script_name:" ' 17 | BEGIN {desc=""} 18 | $0 ~ prefix { 19 | line = $0 20 | sub(prefix, "", line) 21 | sub(/^# */, "", line) 22 | desc = desc (desc ? " " : "") line 23 | next 24 | } 25 | desc != "" {exit} 26 | END {print desc} 27 | ' "$script") 28 | if [ -z "$description" ]; then 29 | description="No description available" 30 | fi 31 | if [ ${#description} -gt 60 ]; then 32 | description=$(echo "$description" | cut -c1-57)... 33 | fi 34 | printf " \033[36m %-25s\033[0m %s\n" "script/$script_name" "$description" 35 | done 36 | 37 | echo "" 38 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | Copyright (c) 2020-2022 Joakim Sørensen 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /.github/workflows/codspeed.yml: -------------------------------------------------------------------------------- 1 | name: CodSpeed 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | pull_request: 8 | branches: 9 | - "main" 10 | 11 | permissions: {} 12 | 13 | jobs: 14 | benchmarks: 15 | name: Run benchmarks 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout the repository 19 | uses: actions/checkout@v6.0.1 20 | 21 | - name: 🛠 Set up Python 3 22 | uses: actions/setup-python@v6.1.0 23 | id: python 24 | with: 25 | python-version: 3.x 26 | 27 | - name: Install uv 28 | uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 29 | with: 30 | version: "0.9.18" 31 | 32 | - name: Install dependencies 33 | run: script/bootstrap 34 | 35 | - name: Run benchmarks 36 | uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1 37 | with: 38 | token: ${{ secrets.CODSPEED_TOKEN }} 39 | run: uv run --dev pytest -x --no-cov -vvvvv --codspeed benchmarks 40 | mode: instrumentation 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.yml: -------------------------------------------------------------------------------- 1 | name: "Report a bug with AwesomeVersion" 2 | description: Report an issue with AwesomeVersion 3 | labels: "bug" 4 | body: 5 | - type: textarea 6 | attributes: 7 | label: The problem 8 | placeholder: >- 9 | Describe the issue you are experiencing here to communicate to the 10 | maintainers. Tell us what you were trying to do and what happened. 11 | validations: 12 | required: true 13 | - type: markdown 14 | attributes: 15 | value: | 16 | ## Environment 17 | - type: input 18 | attributes: 19 | label: Operating system 20 | validations: 21 | required: true 22 | - type: dropdown 23 | validations: 24 | required: true 25 | attributes: 26 | label: Python version 27 | options: 28 | - "3.9" 29 | - "3.10" 30 | - "3.11" 31 | - "3.12" 32 | - "3.13" 33 | - type: textarea 34 | validations: 35 | required: true 36 | attributes: 37 | label: Problem-relevant code 38 | description: >- 39 | A minimal example to reproduce the bug 40 | render: python 41 | - type: textarea 42 | attributes: 43 | label: Traceback/Error logs 44 | description: >- 45 | If you come across any trace or error logs, please provide them. 46 | render: txt 47 | - type: textarea 48 | attributes: 49 | label: Additional information -------------------------------------------------------------------------------- /tests/test_coverage_edge_cases.py: -------------------------------------------------------------------------------- 1 | """Tests for edge cases to ensure 100% code coverage.""" 2 | 3 | from __future__ import annotations 4 | 5 | from unittest.mock import patch 6 | 7 | from awesomeversion import AwesomeVersion, AwesomeVersionStrategy 8 | from awesomeversion.utils.regex import get_compiled_pattern 9 | 10 | 11 | def test_hexver_modifier_type() -> None: 12 | """Test that HexVer strategy returns None for modifier_type.""" 13 | av = AwesomeVersion("0xABCD") 14 | assert av.strategy == AwesomeVersionStrategy.HEXVER 15 | assert av.modifier_type is None 16 | 17 | 18 | def test_get_compiled_pattern_missing() -> None: 19 | """Test get_compiled_pattern with non-existent pattern name.""" 20 | result = get_compiled_pattern("NON_EXISTENT_PATTERN") 21 | assert result is None 22 | 23 | 24 | def test_buildver_section_valueerror() -> None: 25 | """Test BuildVer section method ValueError handling.""" 26 | av = AwesomeVersion("123") 27 | assert av.strategy == AwesomeVersionStrategy.BUILDVER 28 | 29 | # Mock the string property to return something that will cause ValueError in int() 30 | with patch.object( 31 | type(av), "string", new_callable=lambda: property(lambda self: "not_a_number") 32 | ): 33 | result = av.section(0) 34 | assert result == 0 # Should return 0 due to ValueError 35 | -------------------------------------------------------------------------------- /.devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "AwesomeVersion", 3 | "image": "mcr.microsoft.com/vscode/devcontainers/python:1-3.9", 4 | "postCreateCommand": "script/setup", 5 | "postStartCommand": "script/motd", 6 | "features": { 7 | "ghcr.io/va-h/devcontainers-features/uv:1": { 8 | "version": "0.7.19", 9 | "shellautocompletion": true 10 | } 11 | }, 12 | "customizations": { 13 | "vscode": { 14 | "settings": { 15 | "python.defaultInterpreterPath": "/usr/local/bin/python", 16 | "python.linting.enabled": true, 17 | "python.linting.pylintEnabled": true, 18 | "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", 19 | "python.formatting.blackPath": "/usr/local/py-utils/bin/black", 20 | "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", 21 | "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", 22 | "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", 23 | "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", 24 | "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", 25 | "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", 26 | "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" 27 | }, 28 | "extensions": [ 29 | "ms-python.python", 30 | "ms-python.vscode-pylance", 31 | "GitHub.copilot" 32 | ] 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /benchmarks/test_constructor.py: -------------------------------------------------------------------------------- 1 | """Constructor benchmarks for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Any 6 | 7 | import pytest 8 | 9 | from awesomeversion import AwesomeVersion, AwesomeVersionStrategy 10 | 11 | from .const import DEFAULT_RUNS 12 | 13 | semver_first = { 14 | "ensure_strategy": AwesomeVersionStrategy.SEMVER, 15 | "find_first_match": True, 16 | } 17 | 18 | 19 | @pytest.mark.benchmark 20 | @pytest.mark.parametrize( 21 | "version,constructor_kv", 22 | [ 23 | pytest.param("9999", {}, id="9999-default"), 24 | pytest.param("v1.2.3", {}, id="v1.2.3-default"), 25 | pytest.param( 26 | "lorem_ipsum1.2.3", 27 | semver_first, 28 | id="lorem_ipsum1.2.3-semver-first", 29 | ), 30 | pytest.param("dev", {}, id="dev-default"), 31 | pytest.param(1, {}, id="1-as-int-default"), 32 | pytest.param("1", {}, id="1-as-str-default"), 33 | pytest.param(3.14, {}, id="3.14-as-float-default"), 34 | pytest.param( 35 | "1.2.3", 36 | semver_first, 37 | id="1.2.3-semver-first", 38 | ), 39 | ], 40 | ) 41 | def test_constructor( 42 | version: str | int | float, constructor_kv: dict[str, Any] 43 | ) -> None: 44 | """Benchmark for AwesomeVersion constructor.""" 45 | for _ in range(DEFAULT_RUNS): 46 | assert AwesomeVersion(version, **constructor_kv) 47 | -------------------------------------------------------------------------------- /tests/test_snapshots.py: -------------------------------------------------------------------------------- 1 | """Testing with snapshots.""" 2 | 3 | import json 4 | 5 | import pytest 6 | from pytest_snapshot.plugin import Snapshot # type: ignore 7 | 8 | from awesomeversion import AwesomeVersion 9 | from awesomeversion.typing import VersionType 10 | 11 | from .test_versions import TEST_VERSIONS 12 | 13 | 14 | @pytest.mark.parametrize("version", TEST_VERSIONS) 15 | def test_awesomeversion_output_with_snapshot( 16 | version: VersionType, 17 | snapshot: Snapshot, 18 | ) -> None: 19 | """Test AwesomeVersion output with snapshot.""" 20 | version_obj = AwesomeVersion(version) 21 | 22 | snapshot.snapshot_dir = f"tests/snapshots/{version_obj.strategy.value}" 23 | snapshot.assert_match( 24 | json.dumps( 25 | { 26 | key: getattr(version_obj, key) 27 | for key in [ 28 | "alpha", 29 | "beta", 30 | "dev", 31 | "major", 32 | "micro", 33 | "minor", 34 | "modifier_type", 35 | "modifier", 36 | "patch", 37 | "prefix", 38 | "release_candidate", 39 | "sections", 40 | "simple", 41 | "strategy", 42 | "string", 43 | "valid", 44 | "year", 45 | ] 46 | }, 47 | indent=4, 48 | ), 49 | f"{version}.json", 50 | ) 51 | -------------------------------------------------------------------------------- /benchmarks/test_properties.py: -------------------------------------------------------------------------------- 1 | """Property benchmarks for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | from pytest_codspeed import BenchmarkFixture 7 | 8 | from awesomeversion import AwesomeVersion, AwesomeVersionStrategy 9 | 10 | from .const import DEFAULT_RUNS 11 | 12 | semver_first = { 13 | "ensure_strategy": AwesomeVersionStrategy.SEMVER, 14 | "find_first_match": True, 15 | } 16 | 17 | 18 | @pytest.mark.parametrize( 19 | "version,class_property", 20 | ( 21 | *[(version, "prefix") for version in ("v1.2.3", "v.1.2.3", "1.2.3")], 22 | *[(version, "modifier") for version in ("1.2.3-dev2", "1.2.3dev2")], 23 | *[(version, "modifier_type") for version in ("1.2.3.dev0", "1.2.3.beta0")], 24 | *[(version, "strategy") for version in ("1.2.3", "2099.1.1", "999")], 25 | *[ 26 | (version, "strategy_description") 27 | for version in ("1.2.3", "2099.1.1", "999") 28 | ], 29 | *[ 30 | (version, segment) 31 | for version in ("1.2.3", "123", "0.1.2.3") 32 | for segment in ("major", "minor", "patch") 33 | ], 34 | ), 35 | ) 36 | def test_property( 37 | benchmark: BenchmarkFixture, 38 | version: str | int | float, 39 | class_property: str, 40 | ) -> None: 41 | """Benchmark for AwesomeVersion properties.""" 42 | obj = AwesomeVersion(version) 43 | 44 | @benchmark 45 | def _run_benchmark() -> None: 46 | for _ in range(DEFAULT_RUNS): 47 | getattr(obj, class_property) 48 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | permissions: {} 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | name: Build package 14 | steps: 15 | - name: Checkout the repository 16 | uses: actions/checkout@v6.0.1 17 | 18 | - name: Set up Python 3.x 19 | uses: actions/setup-python@v6 20 | with: 21 | python-version: 3.x 22 | 23 | - name: Install uv 24 | uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 25 | with: 26 | version: "0.9.18" 27 | 28 | - name: Set version number 29 | run: script/set-version ${{ github.event.release.tag_name }} 30 | 31 | - name: Build 32 | run: uv build 33 | 34 | - name: Upload dists 35 | uses: actions/upload-artifact@v6.0.0 36 | with: 37 | name: "dist" 38 | path: "dist/" 39 | if-no-files-found: error 40 | retention-days: 5 41 | 42 | publish: 43 | name: Publish release to PyPI 44 | runs-on: ubuntu-latest 45 | needs: "build" 46 | environment: 47 | name: release 48 | url: https://pypi.org/project/awesomeversion 49 | permissions: 50 | id-token: write 51 | steps: 52 | - name: Download dists 53 | uses: actions/download-artifact@v7.0.0 54 | with: 55 | name: "dist" 56 | path: "dist/" 57 | 58 | - name: Publish dists to PyPI 59 | uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 -------------------------------------------------------------------------------- /benchmarks/test_compare.py: -------------------------------------------------------------------------------- 1 | """Compare benchmarks for AwesomeVersion.""" 2 | 3 | import pytest 4 | from pytest_codspeed import BenchmarkFixture 5 | 6 | from awesomeversion import AwesomeVersion 7 | 8 | from .const import DEFAULT_RUNS 9 | 10 | 11 | @pytest.mark.parametrize( 12 | "input_a,operator, input_b", 13 | ( 14 | pytest.param("9999", ">", "1", id="9999>1"), 15 | pytest.param("9999", ">", "2020.1.1", id="9999>2020.1.1"), 16 | pytest.param("1.2.3b6", ">", "1.2.3.dev4", id="1.2.3b6>1.2.3.dev4"), 17 | pytest.param("1.2.3", "==", "1.2.3", id="1.2.3==1.2.3"), 18 | pytest.param("1.2.3", "!=", "3.2.1", id="1.2.3!=3.2.1"), 19 | ), 20 | ) 21 | def test_compare( 22 | benchmark: BenchmarkFixture, 23 | input_a: str, 24 | operator: str, 25 | input_b: str, 26 | ) -> None: 27 | """Benchmark for AwesomeVersion comparison.""" 28 | obj = AwesomeVersion(input_a) 29 | if operator == ">": 30 | 31 | @benchmark 32 | def _run_benchmark() -> None: 33 | for _ in range(DEFAULT_RUNS): 34 | assert obj > input_b 35 | 36 | elif operator == "<": 37 | 38 | @benchmark 39 | def _run_benchmark() -> None: 40 | for _ in range(DEFAULT_RUNS): 41 | assert obj < input_b 42 | 43 | elif operator == "==": 44 | 45 | @benchmark 46 | def _run_benchmark() -> None: 47 | for _ in range(DEFAULT_RUNS): 48 | assert obj == input_b 49 | 50 | elif operator == "!=": 51 | 52 | @benchmark 53 | def _run_benchmark() -> None: 54 | for _ in range(DEFAULT_RUNS): 55 | assert obj != input_b 56 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "awesomeversion" 7 | version = "0" 8 | description = "One version package to rule them all, One version package to find them, One version package to bring them all, and in the darkness bind them." 9 | authors = [ 10 | {name = "Ludeeus", email = "joasoe@proton.me"}, 11 | ] 12 | maintainers = [ 13 | {name = "Ludeeus", email = "joasoe@proton.me"}, 14 | ] 15 | license = {text = "MIT"} 16 | readme = "README.md" 17 | keywords = ["calver", "semver", "0ver", "version", "pep440", "buildver"] 18 | classifiers = [ 19 | "Intended Audience :: Developers", 20 | "Natural Language :: English", 21 | "Topic :: Software Development :: Libraries :: Python Modules", 22 | ] 23 | requires-python = ">=3.9" 24 | dependencies = [] 25 | 26 | [project.urls] 27 | Repository = "https://github.com/ludeeus/awesomeversion" 28 | 29 | [project.optional-dependencies] 30 | dev = [ 31 | "black>=25.1", 32 | "isort>=6.0.1", 33 | "mypy>=1.16", 34 | "pylint>=3.3.7", 35 | "pytest>=8.4.1", 36 | "pytest-codspeed==4.2.0", 37 | "pytest-cov>=6.2.1", 38 | "pytest-snapshot>=0.9.0", 39 | "pytest-timeout>=2.4.0", 40 | ] 41 | 42 | 43 | [tool.isort] 44 | combine_as_imports = true 45 | force_sort_within_sections = true 46 | profile = "black" 47 | 48 | [tool.pylint.'MESSAGES CONTROL'] 49 | disable = "unsubscriptable-object,duplicate-code,too-many-public-methods" 50 | 51 | 52 | [tool.coverage.run] 53 | source = ["awesomeversion"] 54 | omit = ["setup.py", "tests/*", "benchmarks/*"] 55 | 56 | [tool.coverage.report] 57 | exclude_lines = ["if TYPE_CHECKING:"] 58 | 59 | [tool.hatch.build.targets.wheel] 60 | packages = ["awesomeversion"] 61 | -------------------------------------------------------------------------------- /tests/issues/test_issue96.py: -------------------------------------------------------------------------------- 1 | """Test for issue #96.""" 2 | 3 | # https://github.com/ludeeus/awesomeversion/issues/96 4 | import re 5 | 6 | import pytest 7 | 8 | from awesomeversion import ( 9 | AwesomeVersion, 10 | AwesomeVersionStrategy, 11 | AwesomeVersionStrategyException, 12 | ) 13 | 14 | 15 | def test() -> None: 16 | """Test for issue #96.""" 17 | version = AwesomeVersion("10.3.0", ensure_strategy=AwesomeVersionStrategy.SEMVER) 18 | assert version.strategy == AwesomeVersionStrategy.SEMVER 19 | 20 | version = AwesomeVersion( 21 | "10.3.0", 22 | ensure_strategy=[ 23 | AwesomeVersionStrategy.CALVER, 24 | AwesomeVersionStrategy.SEMVER, 25 | AwesomeVersionStrategy.SIMPLEVER, 26 | AwesomeVersionStrategy.BUILDVER, 27 | AwesomeVersionStrategy.PEP440, 28 | ], 29 | ) 30 | assert version.strategy == AwesomeVersionStrategy.CALVER 31 | 32 | version = AwesomeVersion( 33 | "10.3.0", 34 | ensure_strategy=[ 35 | AwesomeVersionStrategy.SEMVER, 36 | AwesomeVersionStrategy.CALVER, 37 | ], 38 | ) 39 | assert version.strategy == AwesomeVersionStrategy.SEMVER 40 | 41 | with pytest.raises( 42 | AwesomeVersionStrategyException, 43 | match=re.escape( 44 | "Strategy unknown does not match ['SemVer', 'CalVer'] for whatever" 45 | ), 46 | ): 47 | AwesomeVersion( 48 | "whatever", 49 | ensure_strategy=[ 50 | AwesomeVersionStrategy.SEMVER, 51 | AwesomeVersionStrategy.CALVER, 52 | ], 53 | ) 54 | 55 | with pytest.raises( 56 | AwesomeVersionStrategyException, 57 | match=re.escape("Strategy CalVer does not match ['SemVer'] for 2021.12"), 58 | ): 59 | AwesomeVersion("2021.12", ensure_strategy=AwesomeVersionStrategy.SEMVER) 60 | -------------------------------------------------------------------------------- /tests/issues/test_issue422.py: -------------------------------------------------------------------------------- 1 | """Test for issue #422 - Compound modifier comparison.""" 2 | 3 | from awesomeversion import AwesomeVersion, AwesomeVersionStrategy 4 | 5 | 6 | def test() -> None: 7 | """Test comparing versions with compound modifiers like beta1-dev127513.""" 8 | installed_version = "1.7.0-beta1-dev127513" 9 | latest_version = "1.7.0-beta2" 10 | 11 | installed_awesome = AwesomeVersion( 12 | installed_version, 13 | find_first_match=True, 14 | ensure_strategy=[AwesomeVersionStrategy.SEMVER], 15 | ) 16 | 17 | latest_awesome = AwesomeVersion( 18 | latest_version, 19 | find_first_match=True, 20 | ensure_strategy=[AwesomeVersionStrategy.SEMVER], 21 | ) 22 | 23 | # Both should be treated as SEMVER 24 | assert installed_awesome.strategy == AwesomeVersionStrategy.SEMVER 25 | assert latest_awesome.strategy == AwesomeVersionStrategy.SEMVER 26 | 27 | # Both should extract the correct modifier type 28 | assert installed_awesome.modifier_type == "beta" 29 | assert latest_awesome.modifier_type == "beta" 30 | 31 | # Both should have modifiers (not None) 32 | assert installed_awesome.modifier is not None 33 | assert latest_awesome.modifier is not None 34 | 35 | # The modifier comparison should work 36 | assert installed_awesome.modifier < latest_awesome.modifier 37 | 38 | # The main comparison should work (this was the reported issue) 39 | assert ( 40 | installed_awesome < latest_awesome 41 | ), f"{installed_awesome} should be less than {latest_awesome}" 42 | 43 | # Test some additional compound modifier scenarios 44 | dev_version = AwesomeVersion( 45 | "1.0.0-dev123", ensure_strategy=[AwesomeVersionStrategy.SEMVER] 46 | ) 47 | alpha_compound = AwesomeVersion( 48 | "1.0.0-alpha1-build456", ensure_strategy=[AwesomeVersionStrategy.SEMVER] 49 | ) 50 | 51 | assert dev_version.modifier_type == "dev" 52 | assert alpha_compound.modifier_type == "alpha" 53 | 54 | # dev < alpha according to SEMVER_MODIFIER_MAP 55 | assert dev_version < alpha_compound 56 | -------------------------------------------------------------------------------- /tests/test_version_scheme.py: -------------------------------------------------------------------------------- 1 | """Test test_version_scheme.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | from awesomeversion import AwesomeVersion 8 | from awesomeversion.strategy import AwesomeVersionStrategy 9 | from awesomeversion.typing import VersionType 10 | 11 | 12 | @pytest.mark.parametrize( 13 | "version,strategy,dev,beta,modifier_type", 14 | [ 15 | ("0.118.0", AwesomeVersionStrategy.SEMVER, False, False, None), 16 | ("1.0.0b1", AwesomeVersionStrategy.PEP440, False, True, "b"), 17 | ("1.0.0-beta.1", AwesomeVersionStrategy.SEMVER, False, True, "beta"), 18 | ("v1.0.0-beta.1", AwesomeVersionStrategy.SEMVER, False, True, "beta"), 19 | ("2021.2.0.dev1", AwesomeVersionStrategy.CALVER, True, False, "dev"), 20 | ("stable", AwesomeVersionStrategy.SPECIALCONTAINER, False, False, None), 21 | ], 22 | ) 23 | def test_version_scheme( 24 | version: VersionType, 25 | strategy: AwesomeVersionStrategy, 26 | dev: bool, 27 | beta: bool, 28 | modifier_type: str | None, 29 | ) -> None: 30 | """Test that the version matches the expected scheme.""" 31 | version_object = AwesomeVersion(version) 32 | assert str(version_object) == version 33 | assert version_object.strategy == strategy 34 | assert version_object.dev == dev 35 | assert version_object.beta == beta 36 | assert version_object.modifier_type == modifier_type 37 | 38 | 39 | def test_semver_sections() -> None: 40 | """Test semver sections.""" 41 | ver_a = AwesomeVersion("1.0.0-beta.1") 42 | ver_b = AwesomeVersion("2.0.0") 43 | assert ver_a.strategy == AwesomeVersionStrategy.SEMVER 44 | assert ver_b.strategy == AwesomeVersionStrategy.SEMVER 45 | 46 | assert ver_a.major == "1" 47 | assert ver_a.minor == "0" 48 | assert ver_a.patch == "0" 49 | 50 | assert ver_a.major < ver_b.major 51 | 52 | 53 | def test_named_sections() -> None: 54 | """Test named sections.""" 55 | version = AwesomeVersion("2020.1.1") 56 | assert version.major == version.year == "2020" 57 | assert version.minor == "1" 58 | assert version.patch == "1" 59 | assert version.micro == version.patch == "1" 60 | 61 | 62 | def test_named_sections_invalid() -> None: 63 | """Test invalid named sections.""" 64 | version = AwesomeVersion("latest") 65 | assert version.major is None 66 | assert version.minor is None 67 | assert version.patch is None 68 | 69 | assert version.year == version.major 70 | assert version.micro == version.patch 71 | -------------------------------------------------------------------------------- /awesomeversion/comparehandlers/sections.py: -------------------------------------------------------------------------------- 1 | """Special handler for sections.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import TYPE_CHECKING 6 | 7 | from ..utils.regex import RE_IS_SINGLE_DIGIT, RE_MODIFIER 8 | 9 | if TYPE_CHECKING: 10 | from ..awesomeversion import AwesomeVersion 11 | 12 | MODIFIERS = {"rc": 3, "beta": 2, "b": 2, "alpha": 1, "a": 1, "dev": 0, "d": 0} 13 | 14 | 15 | def compare_handler_sections( 16 | version_a: AwesomeVersion, 17 | version_b: AwesomeVersion, 18 | ) -> bool | None: 19 | """Compare handler sections.""" 20 | base = compare_base_sections(version_a, version_b) 21 | if base is not None: 22 | return base 23 | return compare_modifier_section(version_a, version_b) 24 | 25 | 26 | def compare_base_sections( 27 | version_a: AwesomeVersion, 28 | version_b: AwesomeVersion, 29 | ) -> bool | None: 30 | """Compare base sections between two AwesomeVersion objects.""" 31 | biggest = ( 32 | version_a.sections 33 | if version_a.sections >= version_b.sections 34 | else version_b.sections 35 | ) 36 | for section in range(0, biggest): 37 | ver_a_section = version_a.section(section) 38 | ver_b_section = version_b.section(section) 39 | if ver_a_section == ver_b_section: 40 | continue 41 | if ver_a_section > ver_b_section: 42 | return True 43 | if ver_a_section < ver_b_section: 44 | return False 45 | return None 46 | 47 | 48 | def compare_modifier_section( 49 | version_a: AwesomeVersion, 50 | version_b: AwesomeVersion, 51 | ) -> bool | None: 52 | """Compare modifiers between two AwesomeVersion objects.""" 53 | if version_a.modifier is None and version_b.modifier is not None: 54 | return True 55 | if version_a.modifier is not None and version_b.modifier is not None: 56 | version_a_modifier = RE_MODIFIER.match(version_a.string.split(".")[-1]) 57 | version_b_modifier = RE_MODIFIER.match(version_b.string.split(".")[-1]) 58 | if version_a_modifier and version_b_modifier: 59 | if version_a_modifier.group(3) == version_b_modifier.group(3): 60 | return int(version_a_modifier.group(4) or 0) > int( 61 | version_b_modifier.group(4) or 0 62 | ) 63 | mod_a = MODIFIERS.get(version_a_modifier.group(3)) 64 | mod_b = MODIFIERS.get(version_b_modifier.group(3)) 65 | if mod_a is not None and mod_b is not None: 66 | return mod_a > mod_b 67 | return version_a_modifier.group(3) > version_b_modifier.group(3) 68 | if RE_IS_SINGLE_DIGIT.match(version_a.modifier) and RE_IS_SINGLE_DIGIT.match( 69 | version_b.modifier 70 | ): 71 | return int(version_a.modifier) > int(version_b.modifier) 72 | return None 73 | -------------------------------------------------------------------------------- /awesomeversion/utils/regex.py: -------------------------------------------------------------------------------- 1 | """Regex utils for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | from functools import lru_cache 6 | import re 7 | from typing import Pattern 8 | 9 | RE_IS_SINGLE_DIGIT = re.compile(r"^\d$") 10 | RE_DIGIT = re.compile(r"[a-z]*(\d+)[a-z]*") 11 | RE_MODIFIER = re.compile(r"^((?:\d+\-|\d|))(([a-z]+)\.?(\d*))$") 12 | RE_COMPOUND_MODIFIER = re.compile(r"^([a-z]+)(\d*)-.*$") 13 | RE_MODIFIER_COMPOUND_PART = re.compile(r"^([a-z]+)(\d*)$") 14 | 15 | 16 | RE_CALVER = r"(\d{2}|\d{4})\.\d{1,2}?(\.?\d{1,2}?\.?)?(\.\d)?(\d*(\w+\d+)?)" 17 | 18 | RE_SEMVER = ( 19 | r"(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)" 20 | r"(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?" 21 | ) 22 | 23 | 24 | RE_PEP440 = ( 25 | r"([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*" 26 | r"([-_\.]?(?:alpha|beta|c|pre|preview|a|b|rc)(0|[1-9][0-9]*))?" 27 | r"([-_\.]?(?:post|r|rev)(0|[1-9][0-9]*))?" 28 | r"([-_\.]?(?:d|dev)(0|[1-9][0-9]*))?" 29 | r"(?:\+([a-z0-9]+(?:[-_\.][a-z0-9]+)*))?" 30 | ) 31 | 32 | RE_BUILDVER = r"\d+" 33 | RE_HEXVER = r"0x[A-Fa-f0-9]+" 34 | 35 | RE_SPECIAL_CONTAINER = r"(?:latest|dev|stable|beta)" 36 | 37 | RE_SIMPLE = r"[vV]?((\d+)(\.\d+)+)" 38 | 39 | 40 | @lru_cache(maxsize=128) 41 | def compile_regex(pattern: str) -> Pattern[str]: 42 | """Compile a regex with caching to avoid recompilation.""" 43 | return re.compile(pattern) 44 | 45 | 46 | @lru_cache(maxsize=32) 47 | def generate_full_string_regex(string: str) -> Pattern[str]: 48 | """Generate a regex that matches the full string with caching.""" 49 | return compile_regex(r"^" + string + r"$") 50 | 51 | 52 | @lru_cache(maxsize=64) 53 | def match_compound_modifier(modifier: str) -> re.Match[str] | None: 54 | """Match compound modifiers with caching for performance.""" 55 | return RE_COMPOUND_MODIFIER.match(modifier) 56 | 57 | 58 | @lru_cache(maxsize=128) 59 | def match_modifier_compound_part(part: str) -> re.Match[str] | None: 60 | """Match modifier parts with caching for performance.""" 61 | return RE_MODIFIER_COMPOUND_PART.match(part) 62 | 63 | 64 | @lru_cache(maxsize=256) 65 | def extract_digits(text: str) -> list[str]: 66 | """Extract all digits from text with caching for performance.""" 67 | return re.findall(r"(\d+)", text) 68 | 69 | 70 | _COMPILED_PATTERNS = { 71 | "BUILDVER_FULL": re.compile(r"^\d+$"), 72 | "HEXVER_FULL": re.compile(r"^0x[A-Fa-f0-9]+$"), 73 | "SPECIAL_CONTAINER_FULL": re.compile(r"^(?:latest|dev|stable|beta)$"), 74 | "IS_SINGLE_DIGIT": RE_IS_SINGLE_DIGIT, 75 | "DIGIT": RE_DIGIT, 76 | "MODIFIER": RE_MODIFIER, 77 | } 78 | 79 | 80 | def get_compiled_pattern(pattern_name: str) -> Pattern[str] | None: 81 | """Get a pre-compiled pattern for maximum performance.""" 82 | return _COMPILED_PATTERNS.get(pattern_name) 83 | -------------------------------------------------------------------------------- /benchmarks/test_strategy.py: -------------------------------------------------------------------------------- 1 | """Strategy detection benchmarks for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | from pytest_codspeed import BenchmarkFixture 7 | 8 | from awesomeversion import AwesomeVersion, AwesomeVersionStrategy 9 | 10 | from .const import DEFAULT_RUNS 11 | 12 | 13 | @pytest.mark.parametrize( 14 | "version", 15 | ( 16 | "1.2.3", 17 | "1.2.3-alpha1", 18 | "1.2.3-beta.1", 19 | "1.2.3+build.1", 20 | "2020.12.1", 21 | "2020.12", 22 | "20.12.1", 23 | "1.2.3.dev0", 24 | "1.2.3a1", 25 | "1.2.3b2", 26 | "1.2.3rc1", 27 | "123", 28 | "999", 29 | "0x1a2b", 30 | "0xdeadbeef", 31 | "latest", 32 | "dev", 33 | "stable", 34 | "beta", 35 | "1.2", 36 | "1.2.3.4", 37 | "v1.2.3", 38 | "lorem_ipsum1.2.3", 39 | "prefix-1.2.3-suffix", 40 | ), 41 | ) 42 | def test_strategy_detection( 43 | benchmark: BenchmarkFixture, 44 | version: str, 45 | ) -> None: 46 | """Benchmark for AwesomeVersion strategy detection.""" 47 | 48 | @benchmark 49 | def _run_benchmark() -> None: 50 | for _ in range(DEFAULT_RUNS): 51 | obj = AwesomeVersion(version) 52 | _ = obj.strategy 53 | 54 | 55 | @pytest.mark.parametrize( 56 | "version,strategy", 57 | ( 58 | ("lorem_ipsum1.2.3", AwesomeVersionStrategy.SEMVER), 59 | ("prefix-2020.12.1-suffix", AwesomeVersionStrategy.CALVER), 60 | ("text1.2.3.4text", AwesomeVersionStrategy.SIMPLEVER), 61 | ), 62 | ) 63 | def test_find_first_match_strategy( 64 | benchmark: BenchmarkFixture, 65 | version: str, 66 | strategy: AwesomeVersionStrategy, 67 | ) -> None: 68 | """Benchmark for AwesomeVersion with find_first_match enabled.""" 69 | 70 | @benchmark 71 | def _run_benchmark() -> None: 72 | for _ in range(DEFAULT_RUNS): 73 | AwesomeVersion( 74 | version, 75 | ensure_strategy=strategy, 76 | find_first_match=True, 77 | ) 78 | 79 | 80 | @pytest.mark.parametrize( 81 | "version,strategies", 82 | ( 83 | ("1.2.3", [AwesomeVersionStrategy.SEMVER]), 84 | ( 85 | "2020.12.1", 86 | [AwesomeVersionStrategy.CALVER, AwesomeVersionStrategy.SIMPLEVER], 87 | ), 88 | ("999", [AwesomeVersionStrategy.BUILDVER]), 89 | ("1.2.3", [AwesomeVersionStrategy.SEMVER, AwesomeVersionStrategy.PEP440]), 90 | ), 91 | ) 92 | def test_ensure_strategy_validation( 93 | benchmark: BenchmarkFixture, 94 | version: str, 95 | strategies: list[AwesomeVersionStrategy], 96 | ) -> None: 97 | """Benchmark for AwesomeVersion with ensure_strategy validation.""" 98 | 99 | @benchmark 100 | def _run_benchmark() -> None: 101 | for _ in range(DEFAULT_RUNS): 102 | AwesomeVersion(version, ensure_strategy=strategies) 103 | -------------------------------------------------------------------------------- /.github/workflows/actions.yml: -------------------------------------------------------------------------------- 1 | name: Actions 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | 11 | permissions: {} 12 | 13 | jobs: 14 | lint: 15 | name: Lint 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: 📥 Checkout the repository 19 | uses: actions/checkout@v6.0.1 20 | 21 | - name: 🛠 Set up Python 3 22 | uses: actions/setup-python@v6 23 | id: python 24 | with: 25 | python-version: 3.x 26 | 27 | - name: Install uv 28 | uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 29 | with: 30 | version: "0.9.18" 31 | 32 | - name: 📦 Install dependencies 33 | run: script/bootstrap 34 | 35 | - name: 🖤 Lint with Black 36 | run: uv run --dev black --check --fast awesomeversion tests benchmarks 37 | 38 | - name: 🐍 Lint with mypy 39 | run: uv run --dev mypy --strict awesomeversion tests benchmarks 40 | 41 | - name: ✨ Lint with pylint 42 | run: uv run --dev pylint awesomeversion tests benchmarks 43 | 44 | - name: 🔤 Lint with isort 45 | run: uv run --dev isort awesomeversion tests benchmarks --check-only 46 | 47 | test: 48 | name: Test with Python ${{ matrix.entry.version }} 49 | needs: lint 50 | runs-on: ubuntu-latest 51 | strategy: 52 | fail-fast: false 53 | matrix: 54 | entry: 55 | - version: "3.9" 56 | - version: "3.10" 57 | - version: "3.11" 58 | - version: "3.12" 59 | - version: "3.13" 60 | steps: 61 | - name: 📥 Checkout the repository 62 | uses: actions/checkout@v6.0.1 63 | 64 | - name: 🛠️ Set up Python ${{ matrix.entry.version }} 65 | uses: actions/setup-python@v6 66 | with: 67 | python-version: ${{ matrix.entry.version }} 68 | allow-prereleases: ${{ matrix.entry.prereleases || false }} 69 | 70 | - name: Install uv 71 | uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 72 | with: 73 | version: "0.9.18" 74 | 75 | - name: 📦 Install dependencies 76 | run: script/bootstrap 77 | 78 | - name: 🏃 Run tests 79 | run: script/test 80 | 81 | - name: 🛠 Build 82 | run: script/build 83 | 84 | coverage: 85 | name: Upload coverage to Codecov 86 | needs: test 87 | runs-on: ubuntu-latest 88 | steps: 89 | - name: 📥 Checkout the repository 90 | uses: actions/checkout@v6.0.1 91 | with: 92 | fetch-depth: 0 93 | 94 | - name: 🛠️ Set up Python 95 | uses: actions/setup-python@v6 96 | with: 97 | python-version: 3.x 98 | 99 | - name: Install uv 100 | uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 101 | with: 102 | version: "0.9.18" 103 | 104 | - name: 📦 Install dependencies 105 | run: script/bootstrap 106 | 107 | - name: 📤 Upload coverage to Codecov 108 | run: | 109 | script/coverage 110 | curl -sfSL https://codecov.io/bash | bash - -------------------------------------------------------------------------------- /tests/test_strategy.py: -------------------------------------------------------------------------------- 1 | """Test match.""" 2 | 3 | import pytest 4 | 5 | from awesomeversion import AwesomeVersion 6 | from awesomeversion.strategy import AwesomeVersionStrategy 7 | from awesomeversion.typing import VersionType 8 | 9 | 10 | @pytest.mark.parametrize( 11 | "version,strategy", 12 | [ 13 | *[ 14 | (v, AwesomeVersionStrategy.BUILDVER) 15 | for v in ( 16 | "1", 17 | "123", 18 | "0", 19 | ) 20 | ], 21 | *[ 22 | (v, AwesomeVersionStrategy.CALVER) 23 | for v in ( 24 | "20.1.0", 25 | "20.1", 26 | "2021.1.0.0", 27 | ) 28 | ], 29 | *[ 30 | (v, AwesomeVersionStrategy.PEP440) 31 | for v in ( 32 | "1.0a1", 33 | "1.0.dev1", 34 | "1.0b2.post345.dev456", 35 | "1.dev0", 36 | "1.0.dev456", 37 | "1.0a1", 38 | "1.0a2.dev456", 39 | "1.0a12.dev456", 40 | "1.0a12", 41 | "1.0b1.dev456", 42 | "1.0b2", 43 | "1.0+local.1.2.3", 44 | "1.0b2.post345.dev456", 45 | "1.0b2.post345", 46 | "1.0rc1.dev456", 47 | "1.0rc1", 48 | "1.0.post456.dev34", 49 | "1.0.post456", 50 | "1.1.dev1", 51 | "1.1-dev1", 52 | "1.1dev1", 53 | "1.1_dev1", 54 | ) 55 | ], 56 | *[ 57 | (v, AwesomeVersionStrategy.SEMVER) 58 | for v in ( 59 | "0.118.0", 60 | "1.0.0-alpha", 61 | "1.0.0-alpha+1.2", 62 | "1.0.0", 63 | "1.2.3", 64 | "1.8.2-beta.1.10", 65 | "1.8.2-beta.1.13", 66 | "2.1.3", 67 | "2.4.6-8", 68 | "1.8.2-beta.1.10+somebuild", 69 | ) 70 | ], 71 | *[ 72 | (v, AwesomeVersionStrategy.SIMPLEVER) 73 | for v in ( 74 | "1.0", 75 | "0.1", 76 | "1.2.3.4.5", 77 | ) 78 | ], 79 | *[ 80 | (v, AwesomeVersionStrategy.SPECIALCONTAINER) 81 | for v in ( 82 | "beta", 83 | "dev", 84 | "latest", 85 | "stable", 86 | ) 87 | ], 88 | *[ 89 | (v, AwesomeVersionStrategy.UNKNOWN) 90 | for v in ( 91 | "", 92 | "unknown", 93 | None, 94 | False, 95 | True, 96 | str, 97 | AwesomeVersionStrategy, 98 | ) 99 | ], 100 | ], 101 | ) 102 | def test_strategy_match(version: VersionType, strategy: AwesomeVersionStrategy) -> None: 103 | """Test that the version matches the expected strategy.""" 104 | assert AwesomeVersion(version).strategy == strategy 105 | 106 | if strategy != AwesomeVersionStrategy.UNKNOWN: 107 | awesome_version = AwesomeVersion( 108 | version, 109 | ensure_strategy=strategy, 110 | find_first_match=True, 111 | ) 112 | assert awesome_version.valid 113 | assert awesome_version.strategy == strategy 114 | -------------------------------------------------------------------------------- /awesomeversion/strategy.py: -------------------------------------------------------------------------------- 1 | """Strategies for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | from collections.abc import Callable 6 | from dataclasses import dataclass 7 | from enum import Enum 8 | from typing import Pattern, Tuple 9 | 10 | from .utils.regex import ( 11 | RE_BUILDVER, 12 | RE_CALVER, 13 | RE_HEXVER, 14 | RE_PEP440, 15 | RE_SEMVER, 16 | RE_SIMPLE, 17 | RE_SPECIAL_CONTAINER, 18 | generate_full_string_regex, 19 | ) 20 | from .utils.validate import value_is_base16 21 | 22 | 23 | class AwesomeVersionStrategy(str, Enum): 24 | """Strategy enum.""" 25 | 26 | BUILDVER = "BuildVer" 27 | CALVER = "CalVer" 28 | HEXVER = "HexVer" 29 | SEMVER = "SemVer" 30 | SIMPLEVER = "SimpleVer" 31 | PEP440 = "PEP 440" 32 | 33 | UNKNOWN = "unknown" 34 | 35 | SPECIALCONTAINER = "SpecialContainer" 36 | 37 | 38 | @dataclass 39 | class AwesomeVersionStrategyDescription: 40 | """Description of a strategy.""" 41 | 42 | strategy: AwesomeVersionStrategy 43 | regex_string: str 44 | pattern: Pattern[str] 45 | validate: Callable[[str], bool] | None = None 46 | 47 | 48 | COMPARABLE_STRATEGIES = [ 49 | strategy 50 | for strategy in AwesomeVersionStrategy 51 | if strategy 52 | not in (AwesomeVersionStrategy.UNKNOWN, AwesomeVersionStrategy.SPECIALCONTAINER) 53 | ] 54 | 55 | VERSION_STRATEGIES: Tuple[AwesomeVersionStrategyDescription, ...] = ( 56 | AwesomeVersionStrategyDescription( 57 | strategy=AwesomeVersionStrategy.BUILDVER, 58 | regex_string=RE_BUILDVER, 59 | pattern=generate_full_string_regex(RE_BUILDVER), 60 | ), 61 | AwesomeVersionStrategyDescription( 62 | strategy=AwesomeVersionStrategy.CALVER, 63 | regex_string=RE_CALVER, 64 | pattern=generate_full_string_regex(RE_CALVER), 65 | ), 66 | AwesomeVersionStrategyDescription( 67 | strategy=AwesomeVersionStrategy.HEXVER, 68 | regex_string=RE_HEXVER, 69 | pattern=generate_full_string_regex(RE_HEXVER), 70 | validate=value_is_base16, 71 | ), 72 | AwesomeVersionStrategyDescription( 73 | strategy=AwesomeVersionStrategy.SEMVER, 74 | regex_string=RE_SEMVER, 75 | pattern=generate_full_string_regex(RE_SEMVER), 76 | ), 77 | AwesomeVersionStrategyDescription( 78 | strategy=AwesomeVersionStrategy.SPECIALCONTAINER, 79 | regex_string=RE_SPECIAL_CONTAINER, 80 | pattern=generate_full_string_regex(RE_SPECIAL_CONTAINER), 81 | ), 82 | AwesomeVersionStrategyDescription( 83 | strategy=AwesomeVersionStrategy.SIMPLEVER, 84 | regex_string=RE_SIMPLE, 85 | pattern=generate_full_string_regex(RE_SIMPLE), 86 | ), 87 | AwesomeVersionStrategyDescription( 88 | strategy=AwesomeVersionStrategy.PEP440, 89 | regex_string=RE_PEP440, 90 | pattern=generate_full_string_regex(RE_PEP440), 91 | ), 92 | ) 93 | 94 | 95 | VERSION_STRATEGIES_DICT: dict[ 96 | AwesomeVersionStrategy, AwesomeVersionStrategyDescription 97 | ] = {description.strategy: description for description in VERSION_STRATEGIES} 98 | 99 | 100 | VERSIONED_STRATEGIES = frozenset( 101 | { 102 | AwesomeVersionStrategy.SEMVER, 103 | AwesomeVersionStrategy.CALVER, 104 | AwesomeVersionStrategy.SIMPLEVER, 105 | AwesomeVersionStrategy.PEP440, 106 | } 107 | ) 108 | 109 | MAJOR_STRATEGIES = frozenset( 110 | { 111 | *VERSIONED_STRATEGIES, 112 | AwesomeVersionStrategy.BUILDVER, 113 | } 114 | ) 115 | -------------------------------------------------------------------------------- /benchmarks/test_collections.py: -------------------------------------------------------------------------------- 1 | """Sorting and collection benchmarks for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | from pytest_codspeed import BenchmarkFixture 7 | 8 | from awesomeversion import AwesomeVersion 9 | 10 | from .const import DEFAULT_RUNS 11 | 12 | SEMVER_VERSIONS = [ 13 | "1.0.0", 14 | "1.0.1", 15 | "1.1.0", 16 | "1.1.1", 17 | "1.2.0", 18 | "2.0.0", 19 | "2.0.0-alpha", 20 | "2.0.0-alpha.1", 21 | "2.0.0-beta", 22 | "2.0.0-rc.1", 23 | "2.1.0", 24 | "10.0.0", 25 | ] 26 | 27 | CALVER_VERSIONS = [ 28 | "2020.1.1", 29 | "2020.2.1", 30 | "2020.12.1", 31 | "2021.1.1", 32 | "2021.6.15", 33 | "2021.12.25", 34 | "2022.1.1", 35 | "2022.3.14", 36 | "2023.1.1", 37 | ] 38 | 39 | MIXED_VERSIONS = [ 40 | "1.0.0", 41 | "2020.12.1", 42 | "999", 43 | "1.2.3-beta1", 44 | "2021.1.1", 45 | "1000", 46 | "1.2.4", 47 | "2020.6.15", 48 | ] 49 | 50 | 51 | @pytest.mark.parametrize( 52 | "version_list", 53 | ( 54 | pytest.param(SEMVER_VERSIONS, id="semver_versions"), 55 | pytest.param(CALVER_VERSIONS, id="calver_versions"), 56 | pytest.param(MIXED_VERSIONS, id="mixed_versions"), 57 | ), 58 | ) 59 | def test_version_sorting( 60 | benchmark: BenchmarkFixture, 61 | version_list: list[str], 62 | ) -> None: 63 | """Benchmark for sorting lists of AwesomeVersion objects.""" 64 | awesome_versions = [AwesomeVersion(v) for v in version_list] 65 | 66 | @benchmark 67 | def _run_benchmark() -> None: 68 | for _ in range(DEFAULT_RUNS): 69 | sorted(awesome_versions) 70 | 71 | 72 | @pytest.mark.parametrize( 73 | "version_list", 74 | ( 75 | pytest.param(SEMVER_VERSIONS, id="semver_versions"), 76 | pytest.param(CALVER_VERSIONS, id="calver_versions"), 77 | pytest.param(MIXED_VERSIONS, id="mixed_versions"), 78 | ), 79 | ) 80 | def test_version_set_operations( 81 | benchmark: BenchmarkFixture, 82 | version_list: list[str], 83 | ) -> None: 84 | """Benchmark for set operations with AwesomeVersion objects.""" 85 | awesome_versions = [AwesomeVersion(v) for v in version_list] 86 | duplicated_versions = awesome_versions + awesome_versions 87 | 88 | @benchmark 89 | def _run_benchmark() -> None: 90 | for _ in range(DEFAULT_RUNS): 91 | version_set = set(duplicated_versions) 92 | _ = awesome_versions[0] in version_set 93 | _ = version_set | {awesome_versions[1]} 94 | 95 | 96 | @pytest.mark.parametrize( 97 | "version_list", 98 | ( 99 | pytest.param(SEMVER_VERSIONS, id="semver_versions"), 100 | pytest.param(CALVER_VERSIONS, id="calver_versions"), 101 | ), 102 | ) 103 | def test_version_list_creation( 104 | benchmark: BenchmarkFixture, 105 | version_list: list[str], 106 | ) -> None: 107 | """Benchmark for creating lists of AwesomeVersion objects.""" 108 | 109 | @benchmark 110 | def _run_benchmark() -> None: 111 | for _ in range(DEFAULT_RUNS): 112 | _ = [AwesomeVersion(v) for v in version_list] 113 | 114 | 115 | def test_version_min_max_operations( 116 | benchmark: BenchmarkFixture, 117 | ) -> None: 118 | """Benchmark for min/max operations on version lists.""" 119 | awesome_versions = [AwesomeVersion(v) for v in SEMVER_VERSIONS] 120 | 121 | @benchmark 122 | def _run_benchmark() -> None: 123 | for _ in range(DEFAULT_RUNS): 124 | min(awesome_versions) 125 | max(awesome_versions) 126 | -------------------------------------------------------------------------------- /benchmarks/test_operations.py: -------------------------------------------------------------------------------- 1 | """Operations benchmarks for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | from pytest_codspeed import BenchmarkFixture 7 | 8 | from awesomeversion import AwesomeVersion 9 | 10 | from .const import DEFAULT_RUNS 11 | 12 | 13 | @pytest.mark.parametrize( 14 | "version", 15 | ( 16 | "1.2.3", 17 | "2020.12.1", 18 | "v1.2.3-beta1", 19 | "1.2.3.dev4", 20 | "999", 21 | "0x1a2b", 22 | "latest", 23 | ), 24 | ) 25 | def test_string_representation( 26 | benchmark: BenchmarkFixture, 27 | version: str, 28 | ) -> None: 29 | """Benchmark for AwesomeVersion string representation operations.""" 30 | obj = AwesomeVersion(version) 31 | 32 | @benchmark 33 | def _run_benchmark() -> None: 34 | for _ in range(DEFAULT_RUNS): 35 | str(obj) 36 | repr(obj) 37 | 38 | 39 | @pytest.mark.parametrize( 40 | "version", 41 | ( 42 | "1.2.3", 43 | "2020.12.1", 44 | "v1.2.3-beta1", 45 | "1.2.3.dev4", 46 | "999", 47 | "0x1a2b", 48 | "latest", 49 | ), 50 | ) 51 | def test_hash_operation( 52 | benchmark: BenchmarkFixture, 53 | version: str, 54 | ) -> None: 55 | """Benchmark for AwesomeVersion hash operations.""" 56 | obj = AwesomeVersion(version) 57 | 58 | @benchmark 59 | def _run_benchmark() -> None: 60 | for _ in range(DEFAULT_RUNS): 61 | hash(obj) 62 | 63 | 64 | @pytest.mark.parametrize( 65 | "version_a,version_b", 66 | ( 67 | ("1.2.3", "1.2.4"), 68 | ("2020.12.1", "2021.12.1"), 69 | ("1.2.3-beta1", "1.2.3-beta2"), 70 | ("1.2.3", "1.3.0"), 71 | ("999", "1000"), 72 | ), 73 | ) 74 | def test_diff_operation( 75 | benchmark: BenchmarkFixture, 76 | version_a: str, 77 | version_b: str, 78 | ) -> None: 79 | """Benchmark for AwesomeVersion diff operations.""" 80 | obj_a = AwesomeVersion(version_a) 81 | 82 | @benchmark 83 | def _run_benchmark() -> None: 84 | for _ in range(DEFAULT_RUNS): 85 | obj_a.diff(version_b) 86 | 87 | 88 | @pytest.mark.parametrize( 89 | "version,lowest,highest", 90 | ( 91 | ("1.2.3", "1.0.0", "2.0.0"), 92 | ("2020.12.1", "2020.1.1", "2021.1.1"), 93 | ("15", "10", "20"), 94 | ("1.2.3-beta1", "1.2.2", "1.2.4"), 95 | ), 96 | ) 97 | def test_in_range_operation( 98 | benchmark: BenchmarkFixture, 99 | version: str, 100 | lowest: str, 101 | highest: str, 102 | ) -> None: 103 | """Benchmark for AwesomeVersion in_range operations.""" 104 | obj = AwesomeVersion(version) 105 | 106 | @benchmark 107 | def _run_benchmark() -> None: 108 | for _ in range(DEFAULT_RUNS): 109 | obj.in_range(lowest, highest) 110 | 111 | 112 | @pytest.mark.parametrize( 113 | "version,section_idx", 114 | ( 115 | ("1.2.3", 0), 116 | ("1.2.3", 1), 117 | ("1.2.3", 2), 118 | ("2020.12.1", 0), 119 | ("2020.12.1.4", 3), 120 | ), 121 | ) 122 | def test_section_access( 123 | benchmark: BenchmarkFixture, 124 | version: str, 125 | section_idx: int, 126 | ) -> None: 127 | """Benchmark for AwesomeVersion section access.""" 128 | obj = AwesomeVersion(version) 129 | 130 | @benchmark 131 | def _run_benchmark() -> None: 132 | for _ in range(DEFAULT_RUNS): 133 | obj.section(section_idx) 134 | 135 | 136 | @pytest.mark.parametrize( 137 | "version", 138 | ( 139 | "1.2.3-alpha1", 140 | "1.2.3-beta2", 141 | "1.2.3-dev3", 142 | "1.2.3-rc1", 143 | "1.2.3", 144 | ), 145 | ) 146 | def test_boolean_properties( 147 | benchmark: BenchmarkFixture, 148 | version: str, 149 | ) -> None: 150 | """Benchmark for AwesomeVersion boolean properties.""" 151 | obj = AwesomeVersion(version) 152 | 153 | @benchmark 154 | def _run_benchmark() -> None: 155 | for _ in range(DEFAULT_RUNS): 156 | _ = obj.alpha 157 | _ = obj.beta 158 | _ = obj.dev 159 | _ = obj.release_candidate 160 | _ = obj.valid 161 | -------------------------------------------------------------------------------- /benchmarks/test_edge_cases.py: -------------------------------------------------------------------------------- 1 | """Edge cases and complex parsing benchmarks for AwesomeVersion.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | from pytest_codspeed import BenchmarkFixture 7 | 8 | from awesomeversion import AwesomeVersion 9 | 10 | from .const import DEFAULT_RUNS 11 | 12 | COMPLEX_VERSIONS = [ 13 | "1.0.post456.dev34", 14 | "1.0a12.dev456", 15 | "1.0b2.post345.dev456", 16 | "1.0rc1+local.1.2.3", 17 | "2021.2.0.dev20210118", 18 | "2021.1.0dev20210101", 19 | "1.0.0-alpha.1+build.123.456", 20 | "1.8.2-beta.1.10+somebuild", 21 | "1.0.0-alpha+1.2", 22 | "1.2.3.4.5.6.7.8.9", 23 | "1.2.3.4.5.6.6.8", 24 | "v1.2.3-alpha.1", 25 | "V.1.2.3-beta", 26 | "2020.1.1.", 27 | "1.1-dev1", 28 | "1.1_dev1", 29 | "1-dev1", 30 | "1_dev1", 31 | "0", 32 | "", 33 | "0.0.0", 34 | "latest", 35 | "dev", 36 | "stable", 37 | "beta", 38 | "0xdeadbeef", 39 | "0x1a2b3c4d", 40 | "123456789123456789123456789123456789123456789123456789123456789", 41 | "999999999999999999999999999999999999999999999999999999999999999", 42 | ] 43 | 44 | 45 | @pytest.mark.parametrize( 46 | "version", 47 | COMPLEX_VERSIONS, 48 | ) 49 | def test_complex_version_parsing( 50 | benchmark: BenchmarkFixture, 51 | version: str, 52 | ) -> None: 53 | """Benchmark for parsing complex version strings.""" 54 | 55 | @benchmark 56 | def _run_benchmark() -> None: 57 | for _ in range(DEFAULT_RUNS): 58 | AwesomeVersion(version) 59 | 60 | 61 | @pytest.mark.parametrize( 62 | "version", 63 | [ 64 | "1.0.0-alpha.1", 65 | "1.0.post456.dev34", 66 | "1.8.2-beta.1.10+somebuild", 67 | "2021.1.0dev20210101", 68 | "1.2.3.4.5b0", 69 | ], 70 | ) 71 | def test_modifier_parsing( 72 | benchmark: BenchmarkFixture, 73 | version: str, 74 | ) -> None: 75 | """Benchmark for parsing version modifiers.""" 76 | obj = AwesomeVersion(version) 77 | 78 | @benchmark 79 | def _run_benchmark() -> None: 80 | for _ in range(DEFAULT_RUNS): 81 | _ = obj.modifier 82 | _ = obj.modifier_type 83 | 84 | 85 | @pytest.mark.parametrize( 86 | "version", 87 | [ 88 | "v1.2.3", 89 | "V.1.2.3-beta", 90 | "v1.0.0-alpha.1", 91 | "V1.0.post456", 92 | ], 93 | ) 94 | def test_prefix_handling( 95 | benchmark: BenchmarkFixture, 96 | version: str, 97 | ) -> None: 98 | """Benchmark for handling version prefixes.""" 99 | obj = AwesomeVersion(version) 100 | 101 | @benchmark 102 | def _run_benchmark() -> None: 103 | for _ in range(DEFAULT_RUNS): 104 | _ = obj.prefix 105 | _ = obj.string 106 | 107 | 108 | @pytest.mark.parametrize( 109 | "version", 110 | [ 111 | "1.2.3.4.5.6.7.8.9", 112 | "1.2.3.4.5.6.6.8", 113 | "1.2.3.4.5", 114 | "2021.1.0.0", 115 | ], 116 | ) 117 | def test_multi_section_versions( 118 | benchmark: BenchmarkFixture, 119 | version: str, 120 | ) -> None: 121 | """Benchmark for versions with many sections.""" 122 | obj = AwesomeVersion(version) 123 | 124 | @benchmark 125 | def _run_benchmark() -> None: 126 | for _ in range(DEFAULT_RUNS): 127 | _ = obj.sections 128 | _ = obj.major 129 | _ = obj.minor 130 | _ = obj.patch 131 | 132 | 133 | def test_version_nesting_performance( 134 | benchmark: BenchmarkFixture, 135 | ) -> None: 136 | """Benchmark for creating AwesomeVersion from AwesomeVersion.""" 137 | base_version = AwesomeVersion("1.2.3") 138 | 139 | @benchmark 140 | def _run_benchmark() -> None: 141 | for _ in range(DEFAULT_RUNS): 142 | AwesomeVersion(base_version) 143 | 144 | 145 | @pytest.mark.parametrize( 146 | "version_input", 147 | [ 148 | 1, 149 | 123, 150 | 3.14, 151 | 0, 152 | 999999999, 153 | ], 154 | ) 155 | def test_non_string_inputs( 156 | benchmark: BenchmarkFixture, 157 | version_input: int | float, 158 | ) -> None: 159 | """Benchmark for non-string version inputs.""" 160 | 161 | @benchmark 162 | def _run_benchmark() -> None: 163 | for _ in range(DEFAULT_RUNS): 164 | AwesomeVersion(version_input) 165 | -------------------------------------------------------------------------------- /tests/test_versions.py: -------------------------------------------------------------------------------- 1 | """Test versions.""" 2 | 3 | from awesomeversion.strategy import AwesomeVersionStrategy 4 | 5 | TEST_VERSIONS = [ 6 | "", 7 | "0.1", 8 | "0.118.0", 9 | "0", 10 | "1.0.0-alpha.1", 11 | "1.0.0-alpha.2", 12 | "1.0.0-alpha", 13 | "1.0.0-alpha+1.2", 14 | "1.0.0-alpha1", 15 | "1.0.0-alpha10", 16 | "1.0.0-alpha9", 17 | "1.0.0-beta.1", 18 | "1.0.0-beta.10", 19 | "1.0.0-beta.2", 20 | "1.0.0-beta.9", 21 | "1.0.0-beta", 22 | "1.0.0-beta0", 23 | "1.0.0-beta1", 24 | "1.0.0-rc.1", 25 | "1.0.0-rc.2", 26 | "1.0.0-rc0", 27 | "1.0.0", 28 | "1.0.0b0", 29 | "1.0.0b1", 30 | "1.0.0b10", 31 | "1.0.0b9", 32 | "1.0.0beta0", 33 | "1.0.0rc0", 34 | "1.0.1", 35 | "1.0.a0", 36 | "1.0.alpha1", 37 | "1.0.b0", 38 | "1.0.b1", 39 | "1.0.b2", 40 | "1.0.d1", 41 | "1.0.dev0", 42 | "1.0.dev1", 43 | "1.0.dev456", 44 | "1.0.invalid4", 45 | "1.0.post456.dev34", 46 | "1.0.post456", 47 | "1.0.rc2", 48 | "1.0", 49 | "1.0+local.1.2.3", 50 | "1.0a1", 51 | "1.0a12.dev456", 52 | "1.0a12", 53 | "1.0a2.dev456", 54 | "1.0b0", 55 | "1.0b1.dev456", 56 | "1.0b1", 57 | "1.0b2.post345.dev456", 58 | "1.0b2.post345", 59 | "1.0b2", 60 | "1.0rc1.dev456", 61 | "1.0rc1", 62 | "1.0rc1+local.1.2.3", 63 | "1.1.dev1", 64 | "1.1-dev1", 65 | "1.1_dev1", 66 | "1.1", 67 | "1.2.3-1", 68 | "1.2.3-2", 69 | "1.2.3-alpha.1", 70 | "1.2.3-dev.1", 71 | "1.2.3.4.5.6.6.8", 72 | "1.2.3.4.5.6.7.8.9", 73 | "1.2.3.4.5.6.7.8", 74 | "1.2.3.4.5", 75 | "1.2.3.4.5b0", 76 | "1.2.3.4", 77 | "1.2.3", 78 | "1.2b0", 79 | "1.8.2-beta.1.10", 80 | "1.8.2-beta.1.10+somebuild", 81 | "1.8.2-beta.1.13", 82 | "1.dev0", 83 | "1.dev1", 84 | "1-dev1", 85 | "1_dev1", 86 | "1", 87 | "123", 88 | "2.0.0-alpha.1", 89 | "2.0.0-alpha.2", 90 | "2.0.0-beta.1", 91 | "2.0.0-beta.2", 92 | "2.0.0-rc.1", 93 | "2.0.0-rc.2", 94 | "2.0.0", 95 | "2.1.0", 96 | "2.1.1", 97 | "2.1.3", 98 | "2.4.6-8", 99 | "2", 100 | "20.1.0", 101 | "20.1", 102 | "2019", 103 | "2020.1.1.", 104 | "2020.1", 105 | "2020.12.0", 106 | "2020.12.1", 107 | "2020.12.dev1602", 108 | "2020.12.dev1603", 109 | "2020.2.0", 110 | "2020.21.1", 111 | "2020", 112 | "2021.1.0.0", 113 | "2021.1.0.dev0", 114 | "2021.1.0", 115 | "2021.1.0a0", 116 | "2021.1.0b0", 117 | "2021.1.0b1", 118 | "2021.1.0b2", 119 | "2021.1.0dev0", 120 | "2021.1.0dev20210101", 121 | "2021.2.0.dev20210118", 122 | "2021.2.0", 123 | "2021.2.0b0", 124 | "2021.2.0b10", 125 | "2022.01.01", 126 | "2022.01.02", 127 | "2022.02.01", 128 | "2022.02.02", 129 | "2022.03.01", 130 | "2022.03.02", 131 | "2023.01.01", 132 | "2023.01.02", 133 | "2023.02.01", 134 | "2023.02.02", 135 | "2023.03.01", 136 | "2023.03.02", 137 | "3.0.0-alpha.1", 138 | "3.0.0-alpha.2", 139 | "3.0.0-beta.1", 140 | "3.0.0-beta.2", 141 | "3.0.0-rc.1", 142 | "3.0.0-rc.2", 143 | "3.0.0", 144 | "3.0.1", 145 | "4.0.0", 146 | "4.1.0", 147 | "4.2.0", 148 | "5.0.0", 149 | "5.1.0", 150 | "5.1.1", 151 | "5.10", 152 | "5.11", 153 | "6.0.0", 154 | "6.0.dev20210429", 155 | "6.0.rc1", 156 | "6.0", 157 | "6.1.0", 158 | "6.2.0", 159 | "7.0.0", 160 | "7.1.0", 161 | "7.1.1", 162 | "a.b.c", 163 | "beta", 164 | "dev", 165 | "latest", 166 | "stable", 167 | "unknown", 168 | "v1.0.1", 169 | "v1.0", 170 | "v1.1.1", 171 | "v1.1", 172 | "v1.2.1", 173 | "v1.2", 174 | "v2.0.1", 175 | "v2.0", 176 | "v2.1.1", 177 | "v2.1", 178 | "v2.2.1", 179 | "v2.2", 180 | "00AABB00", 181 | "01234567", 182 | "0x0", 183 | "0x01002100", 184 | 0x01002101, 185 | "0X01002604", 186 | "0x2df35", 187 | "0x00AABB00", 188 | "0x23089631", 189 | "0x0g", 190 | AwesomeVersionStrategy, 191 | False, 192 | None, 193 | str, 194 | True, 195 | ] 196 | 197 | 198 | def test_human_error_in_version_list() -> None: 199 | """Test for human error in version list.""" 200 | assert len(TEST_VERSIONS) == len(set(TEST_VERSIONS)) 201 | -------------------------------------------------------------------------------- /awesomeversion/comparehandlers/modifier.py: -------------------------------------------------------------------------------- 1 | """Special handler for modifier.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import TYPE_CHECKING 6 | 7 | from ..strategy import VERSION_STRATEGIES_DICT, AwesomeVersionStrategy 8 | from ..utils.regex import ( 9 | RE_MODIFIER, 10 | extract_digits, 11 | match_compound_modifier, 12 | match_modifier_compound_part, 13 | ) 14 | 15 | SEMVER_MODIFIER_MAP = {"dev": 0, "alpha": 1, "beta": 2, "rc": 3} 16 | 17 | if TYPE_CHECKING: 18 | from awesomeversion import AwesomeVersion 19 | 20 | 21 | def _extract_modifier_info(version_string: str) -> tuple[str | None, str | None]: 22 | """Extract modifier number and full modifier string from version.""" 23 | semver_pattern = VERSION_STRATEGIES_DICT[AwesomeVersionStrategy.SEMVER].pattern 24 | semver_match = semver_pattern.match(version_string) 25 | 26 | if not semver_match or len(semver_match.groups()) < 4: 27 | return None, None 28 | 29 | full_modifier = semver_match.group(4) 30 | modifier_match = RE_MODIFIER.match(full_modifier) 31 | 32 | if modifier_match and len(modifier_match.groups()) >= 4: 33 | modifier_num = modifier_match.group(4) 34 | else: 35 | compound_match = match_compound_modifier(full_modifier) 36 | modifier_num = compound_match.group(2) if compound_match else None 37 | 38 | return modifier_num, full_modifier 39 | 40 | 41 | def _compare_modifier_types(type_a: str, type_b: str) -> bool: 42 | """Compare two modifier types using SEMVER_MODIFIER_MAP or alphabetically.""" 43 | priority_a = SEMVER_MODIFIER_MAP.get(type_a) 44 | priority_b = SEMVER_MODIFIER_MAP.get(type_b) 45 | 46 | if priority_a is not None and priority_b is not None: 47 | return priority_a > priority_b 48 | 49 | return type_a > type_b 50 | 51 | 52 | def _compare_compound_parts(part_a: str, part_b: str) -> bool | None: 53 | """Compare two compound modifier parts. Returns None if equal.""" 54 | mod_match_a = match_modifier_compound_part(part_a) 55 | mod_match_b = match_modifier_compound_part(part_b) 56 | 57 | if mod_match_a and mod_match_b: 58 | type_a, num_a = mod_match_a.groups() 59 | type_b, num_b = mod_match_b.groups() 60 | 61 | if type_a != type_b: 62 | return _compare_modifier_types(type_a, type_b) 63 | 64 | if num_a and num_b: 65 | num_val_a, num_val_b = int(num_a), int(num_b) 66 | if num_val_a != num_val_b: 67 | return num_val_a > num_val_b 68 | 69 | return None 70 | 71 | nums_a = extract_digits(part_a) 72 | nums_b = extract_digits(part_b) 73 | 74 | if nums_a and nums_b: 75 | num_val_a, num_val_b = int(nums_a[0]), int(nums_b[0]) 76 | if num_val_a != num_val_b: 77 | return num_val_a > num_val_b 78 | 79 | return None 80 | 81 | 82 | def _compare_compound_modifiers(full_mod_a: str, full_mod_b: str) -> bool | None: 83 | """Compare compound modifiers after the primary part.""" 84 | parts_a = full_mod_a.split("-")[1:] 85 | parts_b = full_mod_b.split("-")[1:] 86 | 87 | for part_a, part_b in zip(parts_a, parts_b): 88 | result = _compare_compound_parts(part_a, part_b) 89 | if result is not None: 90 | return result 91 | 92 | return len(parts_a) > len(parts_b) if len(parts_a) != len(parts_b) else None 93 | 94 | 95 | def compare_handler_semver_modifier( 96 | version_a: AwesomeVersion, 97 | version_b: AwesomeVersion, 98 | ) -> bool | None: 99 | """Compare handler sections.""" 100 | if ( 101 | AwesomeVersionStrategy.SEMVER not in (version_a.strategy, version_b.strategy) 102 | or version_a.modifier_type is None 103 | or version_b.modifier_type is None 104 | ): 105 | return None 106 | 107 | if version_a.modifier_type != version_b.modifier_type: 108 | mod_a = SEMVER_MODIFIER_MAP.get(version_a.modifier_type) 109 | mod_b = SEMVER_MODIFIER_MAP.get(version_b.modifier_type) 110 | if mod_a is not None and mod_b is not None: 111 | return mod_a > mod_b 112 | 113 | mod_num_a, full_mod_a = _extract_modifier_info(version_a.string) 114 | mod_num_b, full_mod_b = _extract_modifier_info(version_b.string) 115 | 116 | result = None 117 | if mod_num_a and mod_num_b: 118 | primary_diff = int(mod_num_a) - int(mod_num_b) 119 | if primary_diff != 0: 120 | result = primary_diff > 0 121 | elif mod_num_a and not mod_num_b: 122 | result = False 123 | elif not mod_num_a and mod_num_b: 124 | result = True 125 | 126 | if result is None and full_mod_a and full_mod_b: 127 | compound_result = _compare_compound_modifiers(full_mod_a, full_mod_b) 128 | if compound_result is not None: 129 | result = compound_result 130 | 131 | return result if result is not None else False 132 | -------------------------------------------------------------------------------- /tests/test_compare.py: -------------------------------------------------------------------------------- 1 | """Test compare.""" 2 | 3 | import pytest 4 | 5 | from awesomeversion import AwesomeVersion 6 | from awesomeversion.exceptions import AwesomeVersionCompareException 7 | from awesomeversion.typing import VersionType 8 | 9 | 10 | @pytest.mark.parametrize( 11 | "version_a,version_b", 12 | [ 13 | ("1.0.0-beta.10", "1.0.0-beta.9"), 14 | ("1.0.0-alpha10", "1.0.0-alpha9"), 15 | ("2021.2.0", "2021.2.0.dev20210118"), 16 | ("2021.2.0b0", "2021.2.0.dev20210118"), 17 | ("2021.2.0", "2021.2.0b0"), 18 | ("2020.12.1", "2020.12.0"), 19 | ("2", "1"), 20 | ("2", 1), 21 | (2, "1"), 22 | (2, 1), 23 | ("5.11", "5.10"), 24 | ("1.1", "1.0"), 25 | ("2020", "2019"), 26 | ("1.2.3.4", "1.2.3"), 27 | ("2020.1", "2020"), 28 | ("2020.2.0", "2020.1.1."), 29 | ("1.2.3.4.5.6.7.8.9", "1"), 30 | ("2020.12.0", "2020.12.dev1602"), 31 | ("2020.12.dev1603", "2020.12.dev1602"), 32 | ("2021.1.0", "2021.1.0b0"), 33 | ("2021.1.0", "2021.1.0b0"), 34 | ("2021.1.0", "2021.1.0b1"), 35 | ("2021.1.0", "2021.1.0dev20210101"), 36 | ("2021.1.0b0", "2021.1.0a0"), 37 | ("2021.1.0b1", "2021.1.0b0"), 38 | ("2021.1.0b1", "2021.1.0dev0"), 39 | ("2021.1.0b1", "2021.1.0.dev0"), 40 | ("2021.1.0", "2021.1.0.dev0"), 41 | ("2021.2.0", "2021.1.0b0"), 42 | ("2021.2.0b0", "2021.1.0"), 43 | ("2021.2.0b10", "2021.1.0b2"), 44 | ("beta", "stable"), 45 | ("1.2.3-2", "1.2.3-1"), 46 | ("dev", "latest"), 47 | ("latest", "2020.21.1"), 48 | ("latest", "beta"), 49 | ("1.0.0-beta0", "1.0.0-alpha1"), 50 | ("1.0.0-beta", "1.0.0-beta.1"), 51 | ("1.0.0-beta1", "1.0.0-beta"), 52 | ("1.0.0-beta.2", "1.0.0-beta.1"), 53 | ("1.0.0-rc0", "1.0.0-alpha1"), 54 | ("1.0.0-beta", "1.0.0-alpha"), 55 | ("1.0.0", "1.0.0-beta1"), 56 | ("1.0.0", "1.0.0-beta"), 57 | ("6.0.rc1", "6.0.dev20210429"), 58 | ("6.0", "6.0.rc1"), 59 | ("1.2.3.4.5.6.7.8", "1.2.3.4.5.6.6.8"), 60 | ("1.0.0b1", "1.0.0b0"), 61 | ("1.0.0b10", "1.0.0b9"), 62 | ("1.0.0", "1.0.0b0"), 63 | (1.0, "1.0.0rc0"), 64 | ("0x2df35", "1"), 65 | ("0x01002604", "0x01002100"), 66 | ("9", "0x0"), 67 | ], 68 | ) 69 | def test_compare(version_a: VersionType, version_b: VersionType) -> None: 70 | """Test compare.""" 71 | ver_a = AwesomeVersion(version_a) 72 | ver_b = AwesomeVersion(version_b) 73 | 74 | assert ver_a > ver_b 75 | assert ver_a >= ver_b 76 | assert ver_a != ver_b 77 | assert ver_a > version_b 78 | assert ver_a >= version_b 79 | assert ver_a != version_b 80 | assert version_a > ver_b 81 | assert version_a >= ver_b 82 | assert version_a != ver_b 83 | assert ver_b < ver_a 84 | assert ver_b <= ver_a 85 | assert ver_b < version_a 86 | assert ver_b <= version_a 87 | 88 | if str(version_a).endswith("."): 89 | version_a = str(version_a)[:-1] 90 | if str(version_b).endswith("."): 91 | version_b = str(version_b)[:-1] 92 | 93 | assert ver_a.string == str(version_a) 94 | assert ver_b.string == str(version_b) 95 | 96 | 97 | def test_invalid_compare() -> None: 98 | """Test invalid compare.""" 99 | invalid = None 100 | with pytest.raises( 101 | AwesomeVersionCompareException, match="Not a valid AwesomeVersion object" 102 | ): 103 | assert AwesomeVersion("2020.12.1") > invalid 104 | 105 | with pytest.raises( 106 | AwesomeVersionCompareException, match="Not a valid AwesomeVersion object" 107 | ): 108 | assert AwesomeVersion("2020.12.1") < invalid 109 | 110 | with pytest.raises( 111 | AwesomeVersionCompareException, match="Not a valid AwesomeVersion object" 112 | ): 113 | assert AwesomeVersion("2020.12.1") == invalid 114 | 115 | with pytest.raises( 116 | AwesomeVersionCompareException, 117 | match="Can't compare and ", 118 | ): 119 | assert AwesomeVersion("2020.12.1") > AwesomeVersion("string") 120 | 121 | with pytest.raises( 122 | AwesomeVersionCompareException, 123 | match="Can't compare and ", 124 | ): 125 | assert AwesomeVersion("2020.12.1") < AwesomeVersion("") 126 | 127 | with pytest.raises( 128 | AwesomeVersionCompareException, 129 | match="Can't compare and ", 130 | ): 131 | assert AwesomeVersion("2020.12.1") < AwesomeVersion(None) 132 | 133 | 134 | @pytest.mark.parametrize( 135 | "version", 136 | [1, "1", 1.0, "1.0", 5.10, "5.10"], 137 | ) 138 | def test_falsy_compare(version: VersionType) -> None: 139 | """Test compare.""" 140 | ver_a = AwesomeVersion(version) 141 | ver_b = AwesomeVersion(version) 142 | 143 | assert ver_a == ver_b 144 | assert ver_a <= ver_b 145 | assert ver_a >= ver_b 146 | 147 | assert not version != ver_b 148 | assert not version > ver_b 149 | assert not version < ver_b 150 | 151 | assert not ver_a != version 152 | assert not ver_a > version 153 | assert not ver_a < version 154 | -------------------------------------------------------------------------------- /tests/test_handlers.py: -------------------------------------------------------------------------------- 1 | """Test compare handlers.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | from awesomeversion import AwesomeVersion 8 | from awesomeversion.comparehandlers.modifier import compare_handler_semver_modifier 9 | from awesomeversion.comparehandlers.sections import compare_modifier_section 10 | from awesomeversion.typing import VersionType 11 | 12 | 13 | @pytest.mark.parametrize( 14 | "ver_a,ver_b,result", 15 | ( 16 | (False, True, None), 17 | ("2", "1", True), 18 | ("1", "2", False), 19 | ("1", "1", False), 20 | ("1.0", "1.0", False), 21 | ("5.10", "5.10", False), 22 | ("1.2.3.4.5b0", "1.2b0", True), 23 | ("1.0b1", "1.0b0", True), 24 | ("1.0", "1.0b0", True), 25 | ("1.0b0", "1.0b1", False), 26 | ("1.0b0", "1.0", False), 27 | ("1.dev1", "1.dev0", True), 28 | ("1.dev0", "1.dev1", False), 29 | ("latest", "stable", True), 30 | ("1.2.3-dev.1", "1.2.3-alpha.1", False), 31 | ("latest", "1", True), 32 | ("1.2.3.4.5.6.7.8.9", "1.2.3.4.5.6.7.8.9", False), 33 | ("1.0.0", "stable", False), 34 | ("0x01002604", "0x01002604", False), 35 | ("0x01002604", "0x01002100", True), 36 | ("0x01002100", "0x01002604", False), 37 | ), 38 | ) 39 | def test_compare_handlers( 40 | ver_a: VersionType, 41 | ver_b: VersionType, 42 | result: bool | None, 43 | ) -> None: 44 | """Test handlers.""" 45 | version_a = AwesomeVersion(ver_a) 46 | version_b = AwesomeVersion(ver_b) 47 | 48 | if ( 49 | version_a.strategy_description is not None 50 | or version_b.strategy_description is not None 51 | ): 52 | assert (AwesomeVersion(ver_a) > ver_b) == result 53 | 54 | 55 | def test_semver_modifier() -> None: 56 | """Test semver modifier.""" 57 | result = compare_handler_semver_modifier( 58 | AwesomeVersion("1.0"), AwesomeVersion("1.0") 59 | ) 60 | assert result is None 61 | 62 | 63 | @pytest.mark.parametrize( 64 | "ver_a,ver_b,result", 65 | ( 66 | ("1.0.b2", "1.0.invalid4", False), 67 | ("2", "1", None), 68 | ("1.0.rc2", "1.0.dev1", True), 69 | ("1.0.rc2", "1.0.d1", True), 70 | ("1.0.b0", "1.0.dev1", True), 71 | ("1.0.0beta0", "1.0.dev1", True), 72 | ("1.0.b0", "1.0.b1", False), 73 | ("1.0.0beta0", "1.0.dev1", True), 74 | ("1.0.a0", "1.0.dev1", True), 75 | ("1.0.dev0", "1.0.alpha1", False), 76 | ), 77 | ) 78 | def test_compare_modifier_section( 79 | ver_a: VersionType, 80 | ver_b: VersionType, 81 | result: bool | None, 82 | ) -> None: 83 | """Test compare_modifier_section.""" 84 | assert ( 85 | compare_modifier_section(AwesomeVersion(ver_a), AwesomeVersion(ver_b)) == result 86 | ) 87 | 88 | 89 | @pytest.mark.parametrize( 90 | "ver_a,ver_b,result", 91 | ( 92 | ("1.0.0-alpha.1", "1.0.0-beta.1", False), 93 | ("1.0.0-beta.2", "1.0.0-alpha.3", True), 94 | ("1.0.0-rc.1", "1.0.0-beta.5", True), 95 | ("1.0.0-dev.1", "1.0.0-alpha.1", False), 96 | ("1.0.0-alpha.5", "1.0.0-alpha.2", True), 97 | ("1.0.0-beta.10", "1.0.0-beta.15", False), 98 | ( 99 | "1.0.0-alpha1-build123", 100 | "1.0.0-beta2-build456", 101 | False, 102 | ), 103 | ("1.0.0-beta3-dev789", "1.0.0-alpha5-release", True), 104 | ("1.0.0-rc1-snapshot", "1.0.0-beta2-final", True), 105 | ( 106 | "1.0.0-alpha5-build100", 107 | "1.0.0-alpha3-build200", 108 | True, 109 | ), 110 | ("1.0.0-dev2-test", "1.0.0-dev7-patch", False), 111 | ( 112 | "1.0.0-alpha5-build100", 113 | "1.0.0-alpha5-build200", 114 | False, 115 | ), 116 | ( 117 | "1.0.0-alpha5-beta100", 118 | "1.0.0-alpha5-dev100", 119 | True, 120 | ), 121 | ( 122 | "1.0.0-beta3-dev123", 123 | "1.0.0-beta3-dev124", 124 | False, 125 | ), 126 | ( 127 | "1.0.0-beta3-dev124", 128 | "1.0.0-beta3-dev123", 129 | True, 130 | ), 131 | ( 132 | "1.0.0-alpha-build", 133 | "1.0.0-beta-build", 134 | False, 135 | ), 136 | ( 137 | "1.0.0-beta-snapshot", 138 | "1.0.0-alpha-release", 139 | True, 140 | ), 141 | ( 142 | "1.0.0-dev-patch", 143 | "1.0.0-alpha-patch", 144 | False, 145 | ), 146 | ( 147 | "1.0.0-rc-final", 148 | "1.0.0-beta-final", 149 | True, 150 | ), 151 | ( 152 | "1.0.0-alpha-build100", 153 | "1.0.0-alpha-build200", 154 | False, 155 | ), 156 | ( 157 | "1.0.0-beta-dev123", 158 | "1.0.0-beta-alpha456", 159 | False, 160 | ), 161 | ( 162 | "1.0.0-alpha-build", 163 | "1.0.0-alpha-build", 164 | False, 165 | ), 166 | ( 167 | "1.0.0-beta-snapshot", 168 | "1.0.0-beta-final", 169 | True, 170 | ), 171 | ( 172 | "1.0.0-alpha-dev", 173 | "1.0.0-alpha-alpha", 174 | False, 175 | ), 176 | ( 177 | "1.0.0-rc-build-final", 178 | "1.0.0-rc-build-test", 179 | False, 180 | ), 181 | ( 182 | "1.0.0-dev-release", 183 | "1.0.0-dev-release100", 184 | False, 185 | ), 186 | ( 187 | "1.0.0-alpha-test-build", 188 | "1.0.0-alpha-test-dev", 189 | False, 190 | ), 191 | ), 192 | ) 193 | def test_compare_handler_semver_modifier_extended( 194 | ver_a: VersionType, 195 | ver_b: VersionType, 196 | result: bool | None, 197 | ) -> None: 198 | """Test compare_handler_semver_modifier with extended examples.""" 199 | assert ( 200 | compare_handler_semver_modifier(AwesomeVersion(ver_a), AwesomeVersion(ver_b)) 201 | == result 202 | ) 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AwesomeVersion 2 | 3 | [![codecov](https://codecov.io/gh/ludeeus/awesomeversion/branch/main/graph/badge.svg)](https://codecov.io/gh/ludeeus/awesomeversion) 4 | ![python version](https://img.shields.io/badge/Python-3.9=><=3.13-blue.svg) 5 | ![dependencies](https://img.shields.io/badge/Dependencies-0-blue.svg) 6 | [![PyPI](https://img.shields.io/pypi/v/awesomeversion)](https://pypi.org/project/awesomeversion) 7 | ![Actions](https://github.com/ludeeus/awesomeversion/workflows/Actions/badge.svg?branch=main) 8 | 9 | _One version package to rule them all, One version package to find them, One version package to bring them all, and in the darkness bind them._ 10 | 11 | Make anything a version object, and compare against a vast section of other version formats. 12 | 13 | ## Installation 14 | 15 | ```bash 16 | python3 -m pip install awesomeversion 17 | ``` 18 | 19 | 20 | ## Development 21 | 22 | > **Note** 23 | > 24 | > Development is only supported inside the provided devcontainer (such as GitHub Codespaces or VS Code Remote - Containers). Other local or system Python environments are not supported for development or contribution. All scripts and workflows assume the devcontainer environment. 25 | 26 | This project uses the ["Scripts to Rule Them All"](https://github.blog/engineering/scripts-to-rule-them-all/) pattern for development tasks: 27 | 28 | ```bash 29 | # Set up the project for development 30 | ./script/setup 31 | 32 | # Run tests 33 | ./script/test 34 | 35 | # Run linting and formatting 36 | ./script/lint 37 | 38 | # Run coverage 39 | ./script/coverage 40 | ``` 41 | 42 | When using the devcontainer or GitHub Codespaces, a welcome message with available scripts is automatically displayed on startup. 43 | 44 | ## AwesomeVersion class 45 | 46 | The AwesomeVersion class takes a version as the first argument, you can also pass in additional kwargs to customize the version object. 47 | 48 | Argument | Description 49 | --- | --- 50 | `version` | The version string to parse. 51 | `ensure_strategy` | Match the `AwesomeVersion` object against spesific strategies when creating if. If it does not match `AwesomeVersionStrategyException` will be raised 52 | `find_first_match` | If True, the version given will be scanned for the first match of the given `ensure_strategy`. Raises `AwesomeVersionStrategyException` If it is not found for any of the given strategies. 53 | 54 | ## AwesomeVersion methods 55 | 56 |
57 | AwesomeVersion.in_range 58 | 59 | This is a helper method to check if the version is in a range. 60 | This method takes two arguments, `lowest` and `highest`, both are required, and returns a boolean. 61 | 62 | > **Note** This method is the same as doing `lowest <= AwesomeVersion <= highest` 63 | 64 | Example: 65 | 66 | ```python 67 | from awesomeversion import AwesomeVersion 68 | print(AwesomeVersion("1.2.2").in_range("1.2.1", "1.3")) 69 | > True 70 | print(AwesomeVersion("1.2.0").in_range("1.2.1", "1.3")) 71 | > False 72 | ``` 73 | 74 |
75 | 76 |
77 | AwesomeVersion.diff 78 | 79 | This is a helper method to get the difference between two versions. 80 | This method takes one argument which is the version to compare against, and returns a `AwesomeVersionDiff` object. 81 | 82 | > **Note** This method is the same as doing `AwesomeVersion - version` 83 | 84 | Example: 85 | 86 | ```python 87 | from awesomeversion import AwesomeVersion 88 | > print(AwesomeVersion("1.0").diff("2.1")) 89 | AwesomeVersionDiff(major=True, minor=True, patch=False, modifier=False, strategy=False) 90 | ``` 91 | 92 |
93 | 94 | 95 |
96 | AwesomeVersion.section 97 | 98 | This is a helper method to get a section of the version. 99 | This method takes one argument which is the section to get, and returns an integer representing it (or 0 if it does not exist). 100 | 101 | Example: 102 | 103 | ```python 104 | from awesomeversion import AwesomeVersion 105 | > print(AwesomeVersion("1.0").section(0)) 106 | 1 107 | ``` 108 | 109 |
110 | 111 | 112 | ## AwesomeVersion properties 113 | 114 | Argument | Description 115 | --- | --- 116 | `alpha` | This is a boolean representing if the version is an alpha version. 117 | `beta` | This is a boolean representing if the version is a beta version. 118 | `dev` | This is a boolean representing if the version is a dev version. 119 | `major` | This is an `AwesomeVersion` object representing the major version or `None` if not present. 120 | `micro` | This is an `AwesomeVersion` object representing the micro version or `None` if not present. 121 | `minor` | This is an `AwesomeVersion` object representing the minor version or `None` if not present. 122 | `modifier_type` | This is a string representing the modifier type of the version or `None` if not present. 123 | `modifier` | This is a string representing the modifier of the version or `None` if not present. 124 | `patch` | This is an `AwesomeVersion` object representing the patch version or `None` if not present. 125 | `prefix` | This is the prefix of the version or `None` if not present. 126 | `release_candidate` | This is a boolean representing if the version is a release candidate version. 127 | `simple` | This is a boolean representing if the version is a simple version. 128 | `strategy_description` | This is a `AwesomeVersionStrategyDescription` object representing the strategy description of the version. 129 | `strategy` | This is a `AwesomeVersionStrategy` object representing the strategy of the version. 130 | `string` | This is the string representation of the version (without the v prefix if present). 131 | `valid` | This is a boolean representing if the version is valid (not unknown strategy). 132 | `year` | This is alias to `major`, and is an `AwesomeVersion` object representing the year. 133 | 134 | 135 | ## Example usage 136 | 137 | Here are some examples of how you can use this package, more examples can be found in the `tests` directory. 138 | 139 |
140 | Basic compare 141 | 142 | ```python 143 | from awesomeversion import AwesomeVersion 144 | 145 | current = AwesomeVersion("1.2.2") 146 | upstream = AwesomeVersion("1.2.3") 147 | 148 | print(upstream > current) 149 | > True 150 | ``` 151 | 152 |
153 | 154 |
155 | Compare beta version 156 | 157 | ```python 158 | from awesomeversion import AwesomeVersion 159 | 160 | current = AwesomeVersion("2021.1.0") 161 | upstream = AwesomeVersion("2021.1.0b2") 162 | 163 | print(current > upstream) 164 | > True 165 | ``` 166 | 167 |
168 | 169 |
170 | Check if version is a beta version 171 | 172 | ```python 173 | from awesomeversion import AwesomeVersion 174 | 175 | print(AwesomeVersion("1.2.3b0").beta) 176 | > True 177 | 178 | print(AwesomeVersion("1.2.3").beta) 179 | > False 180 | ``` 181 | 182 |
183 | 184 |
185 | Use AwesomeVersion with with ... 186 | 187 | ```python 188 | from awesomeversion import AwesomeVersion 189 | 190 | with AwesomeVersion("20.12.0") as current: 191 | with AwesomeVersion("20.12.1") as upstream: 192 | print(upstream > current) 193 | > True 194 | ``` 195 | 196 |
197 | 198 |
199 | Compare AwesomeVersion with other non-AwesomeVersion formats 200 | 201 | ```python 202 | from awesomeversion import AwesomeVersion 203 | 204 | base = AwesomeVersion("20.12.0") 205 | 206 | print(base > "20.12.1") 207 | > False 208 | 209 | print(base > "19") 210 | > True 211 | 212 | print(base > 5) 213 | > True 214 | ``` 215 | 216 |
217 | 218 | 219 | ## General behavior 220 | 221 | You can test your versions on the [demo page][awesomeversion_demo]. 222 | 223 | ### Modifiers 224 | 225 | When comparing versions with modifiers, if the base version is the same the modifier will be used to determine the order. 226 | If one of the versions do not have a modifier, the one without will be considered newer. 227 | 228 | The order of the modifiers are: 229 | - No modifier 230 | - RC 231 | - Beta 232 | - Alpha 233 | - Dev 234 | 235 |
236 | Examples 237 | 238 | ```python 239 | from awesomeversion import AwesomeVersion 240 | 241 | print(AwesomeVersion("1.0.0") > AwesomeVersion("1.0.0b6")) 242 | > True 243 | print(AwesomeVersion("1.0.0") > AwesomeVersion("1.0.0.dev6")) 244 | > True 245 | print(AwesomeVersion("1.0.0.dev19") > AwesomeVersion("1.0.0b4")) 246 | > False 247 | ``` 248 | 249 |
250 | 251 | 252 | ### Special versions (container) 253 | 254 | There are some special versions for container that are handled differently than typical version formats. 255 | The special versions are in the following order: 256 | - `dev` (newest) 257 | - `latest` 258 | - `beta` 259 | - `stable` (oldest) 260 | 261 | If only the first version is this special version, it will be considered newer. 262 | If only the second version is this special version, it will be considered older. 263 | 264 | 265 |
266 | Examples 267 | 268 | ```python 269 | from awesomeversion import AwesomeVersion 270 | 271 | print(AwesomeVersion("latest") > AwesomeVersion("1.0.0b6")) 272 | > True 273 | print(AwesomeVersion("1.0.0") > AwesomeVersion("latest")) 274 | > False 275 | print(AwesomeVersion("stable") > AwesomeVersion("latest")) 276 | > False 277 | print(AwesomeVersion("beta") > AwesomeVersion("dev")) 278 | > False 279 | ``` 280 | 281 |
282 | 283 | 284 | 285 | 286 | ## Contribute 287 | 288 | **All** contributions are welcome! 289 | 290 | 1. Fork the repository 291 | 2. Clone the repository locally and open the devcontainer or use GitHub codespaces 292 | 3. Do your changes 293 | 4. Lint the files with `script/lint` 294 | 5. Ensure all tests passes with `script/test` 295 | 6. Ensure 100% coverage with `script/coverage` 296 | 7. Commit your work, and push it to GitHub 297 | 8. Create a PR against the `main` branch 298 | 299 | 300 | [awesomeversion_demo]: https://awesomeversion.ludeeus.dev --------------------------------------------------------------------------------