Skip to content

models

Models for managing versioning of software projects.

Classes

Version

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

The specification of a version and its parts.

Functions

bump
bump(component_name: str) -> 'Version'

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

required_components
required_components() -> List[str]

Return the names of the parts that are required.

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

Return the values of the parts.

VersionComponent

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.

Attributes

is_independent property
is_independent: bool

Is the part independent of the other parts?

is_optional property
is_optional: bool

Is the part optional?

value property
value: str

Return the value of the part.

Functions

bump
bump() -> 'VersionComponent'

Return a part with bumped value.

copy
copy() -> 'VersionComponent'

Return a copy of the part.

null
null() -> 'VersionComponent'

Return a part with first value.

VersionComponentSpec

Bases: BaseModel

Configuration of a version component.

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

Attributes

always_increment class-attribute instance-attribute
always_increment: bool = False

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

calver_format class-attribute instance-attribute
calver_format: Optional[str] = None

The format string for a CalVer component.

depends_on class-attribute instance-attribute
depends_on: Optional[str] = None

The name of the component this component depends on.

first_value class-attribute instance-attribute
first_value: Union[str, int, None] = None

The first value to increment from.

independent class-attribute instance-attribute
independent: bool = False

Is the component independent of the other components?

optional_value class-attribute instance-attribute
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.
values class-attribute instance-attribute
values: Optional[list] = None

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

Functions

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

Generate a version component from the configuration.

set_always_increment_with_calver classmethod
set_always_increment_with_calver(data: Any) -> Any

Set always_increment to True if calver_format is present.

VersionSpec

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

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

Functions

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

Generate a version from the given values.

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

Return the parts that depend on the given part.

Functions