version

version#


class Version(package_or_version: object | str)[source]#

Bases: object

Represents a version, specifically the numeric components of a version string.

Suffixes like “rc1” or “-dev” are ignored, i.e. for a version string like “1.2.3rc1”, the components are [1, 2, 3].

Parameters:

package_or_version – a package object (with a __version__ attribute) or a version string like “1.2.3”. If a version contains a suffix (like “1.2.3rc1” or “1.2.3-dev”), the suffix is ignored.

is_at_least(*components: int) bool[source]#

Checks this version against the given version components. This version object must contain at least the respective number of components

Parameters:

components – version components in order (i.e. major, minor, patch, etc.)

Returns:

True if the version is at least the given version, False otherwise

is_at_most(*components: int) bool[source]#

Checks this version against the given version components. This version object must contain at least the respective number of components

Parameters:

components – version components in order (i.e. major, minor, patch, etc.)

Returns:

True if the version is at most the given version, False otherwise

is_equal(*components: int) bool[source]#

Checks this version against the given version components. This version object must contain at least the respective number of components

Parameters:

components – version components in order (i.e. major, minor, patch, etc.)

Returns:

True if the version is the given version, False otherwise