semantic_release.version.declarations.i_version_replacer module

class semantic_release.version.declarations.i_version_replacer.IVersionReplacer[source]

Bases: object

Interface for subclasses that replace a version string in a source file.

Methods generally have a base implementation are implemented here but likely just provide a not-supported message but return gracefully

This class cannot be instantiated directly but must be inherited from and implement the designated abstract methods.

abstract parse() set[Version][source]

Return a set of the versions which can be parsed from the file. Because a source can match in multiple places, this method returns a set of matches. Generally, there should only be one element in this set (i.e. even if the version is specified in multiple places, it should be the same version in each place), but enforcing that condition is not mandatory or expected.

abstract replace(new_version: Version) str[source]

Replace the version in the source content with new_version, and return the updated content.

Parameters:

new_version – The new version number as a Version instance

abstract update_file_w_version(new_version: Version, noop: bool = False) Path | None[source]

This method reads the underlying file, replaces each occurrence of the matched pattern, then writes the updated file.

Parameters:

new_version – The new version number as a Version instance