Skip to main content

sem_ver

This package contains a parser for Semantic Version labels complete with type annotations.

In addition to parsing version labels they may be compared via standard comparison operators and modified directly. Note that comparison operators, including equality, do not consider build information. To test for equality including build information, convert to, and compare strings. SemVer objects may be directly compared to strings, or other objects that can be converted to strings, a ValueError will be raised if the other object is not a valid SemVer.

See https://semver.org for details.

sem_ver.SemVer

sem_ver.validate(version: str) -> bool

Test if string is a valid SemVer.

sem_ver.compare(version_a: str, version_b: str) -> int

Compare two SemVer strings. Will raise ValueError if either string is not a valid SemVer.

sem_ver.force(version: str) -> Optional[SemVer]

Use relaxed parsing rules to attempt to create a SemVer. Returns None if no version info found.

SemVer(version: str = None, major: int = 0, minor: int = 0, patch: int = 0, prerelease: Union[str, Sequence[Union[int, str]]] = '', build: Union[str, Sequence[str]] = '')

Constructor. Will raise ValueError if the passed version string does not match the proper format.

SemVer.major: int

Major version. Changing the major version will reset the minor, patch, prerelease, and build versions.

SemVer.minor: int

Minor version. Changing the minor version will reset the patch, prerelease, and build versions.

SemVer.patch: int

Patch version. Changing the patch version will reset the prerelease and build versions.

SemVer.prerelease: Optional[str]

Prerelease tags as a single string. Will raise ValueError if the prerelease string does not match the proper format.

SemVer.prereleases: List[Union[int, str]]

Prerelease tags as a list of int or string. Does not validate the strings.

SemVer.build: Optional[str]

Build labels as a single string. Will raise ValueError if the build string does not match the proper format.

SemVer.builds: List[str]

Build labels as a list of strings. Does not validate the strings.

SemVer.next_major() -> SemVer

Create a new SemVer for the next major release. Minor, patch, prerelease, and build will be reset.

SemVer.next_minor() -> SemVer

Create a new SemVer for the next minor release. Patch, prerelease, and build will be reset.

SemVer.next_patch() -> SemVer

Create a new SemVer for the next patch release. Prerelease and build will be reset.

SemVer.str() -> str

Convert to string.

Installation

Install with pip:

pip install sem_ver

Metadata

Release files for sem-ver 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for sem-ver 1.2.0
File Interpreter ABI Platform Actions
sem_ver-1.2.0-py3-none-any.whl Python 3 none any Details for sem_ver-1.2.0-py3-none-any.whl

Release files / sem_ver-1.2.0-py3-none-any.whl

Download URL sem_ver-1.2.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88196fe2e86b68d3a05991761b5d44523dc7bd59f574d5d76e9159145ebc3126
BLAKE2b-256 checksum
How to use checksums
cbbdbceddb708be46448b82bc1999b83a221ca027fa8ae7bd6d23078c0c8ed16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

Security for sem-ver 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page