Skip to content

bumpversion.versioning.models ​

Models for managing versioning of software projects.

VersionComponent ​

python
class VersionComponent(values: Optional[list] = None, optional_value: Optional[str] = None, first_value: Union[str, int, None] = None, independent: bool = False, always_increment: bool = False, calver_format: Optional[str] = None, source: Optional[str] = None, value: Union[str, int, None] = None)

Represent part of a version number.

Determines the PartFunction that rules how the part behaves when increased or reset based on the configuration given.

value ​

python
value: str

The value of the part.

copy ​

python
def copy() -> VersionComponent

Return a copy of the part.

bump ​

python
def bump() -> VersionComponent

Return a part with bumped value.

bump_to ​

python
def bump_to(value: str) -> VersionComponent

Return a part set to the given value. Raises a ValueError if the value is not valid for the part.

null ​

python
def null() -> VersionComponent

Return a part with first value.

is_optional ​

python
is_optional: bool

Is the part optional?

is_independent ​

python
is_independent: bool

Is the part independent of the other parts?

VersionComponentSpec ​

python
class VersionComponentSpec()

Configuration of a version component.

This is used to read in the configuration from the bumpversion config file.

values ​

python
values: Optional[list] = None

The possible values for the component. If it and calver_format is None, the component is numeric.

optional_value ​

python
optional_value: Optional[str] = None

The value that is optional to include in the version.

  • Defaults to first value in values or 0 in the case of numeric.
  • Empty string means nothing is optional.
  • CalVer components ignore this.

first_value ​

python
first_value: Union[str, int, None] = None

The first value to increment from.

independent ​

python
independent: bool = False

Is the component independent of the other components?

always_increment ​

python
always_increment: bool = False

Should the component always increment, even if it is not necessary?

calver_format ​

python
calver_format: Optional[str] = None

The format string for a CalVer component.

depends_on ​

python
depends_on: Optional[str] = None

The name of the component this component depends on.

set_always_increment_with_calver ​

python
def set_always_increment_with_calver(data: Any) -> Any

Set always_increment to True if calver_format is present.

create_component ​

python
def create_component(value: Union[str, int, None] = None) -> VersionComponent

Generate a version component from the configuration.

VersionSpec ​

python
class VersionSpec(components: Dict[str, VersionComponentSpec], order: Optional[List[str]] = None)

The specification of a version's components and their relationships.

create_version ​

python
def create_version(values: Dict[str, str]) -> Version

Generate a version from the given values.

get_dependents ​

python
def get_dependents(component_name: str) -> List[str]

Return the parts that depend on the given part.

Version ​

python
class Version(version_spec: VersionSpec, components: Dict[str, VersionComponent], original: Optional[str] = None)

The specification of a version and its parts.

values ​

python
def values() -> Dict[str, VersionComponent]

Return the values of the parts.

required_components ​

python
def required_components() -> List[str]

Return the names of the parts that are required.

bump ​

python
def bump(component_name: str) -> Version

Increase the value of the specified component, reset its dependents, and return a new Version.

bump_to ​

python
def bump_to(component_name: str, value: str) -> Version

Set the specified component to value, reset its dependents, and return a new Version.