Source code in backend/src/hatchling/version/scheme/plugin/interface.py
classVersionSchemeInterface(ABC):# no cov""" Example usage: ```python tab="plugin.py" from hatchling.version.scheme.plugin.interface import VersionSchemeInterface class SpecialVersionScheme(VersionSchemeInterface): PLUGIN_NAME = 'special' ... ``` ```python tab="hooks.py" from hatchling.plugin import hookimpl from .plugin import SpecialVersionScheme @hookimpl def hatch_register_version_scheme(): return SpecialVersionScheme ``` """PLUGIN_NAME=''"""The name used for selection."""def__init__(self,root:str,config:dict)->None:self.__root=rootself.__config=config@propertydefroot(self)->str:""" The root of the project tree as a string. """returnself.__root@propertydefconfig(self)->dict:""" ```toml config-example [tool.hatch.version] ``` """returnself.__config@cached_propertydefvalidate_bump(self)->bool:""" This is the value of the `validate-bump` option, with the `HATCH_VERSION_VALIDATE_BUMP` environment variable taking precedence. Validation is enabled by default. ```toml config-example [tool.hatch.version] validate-bump = true ``` """fromhatchling.utils.constantsimportVersionEnvVarsifVersionEnvVars.VALIDATE_BUMPinos.environ:returnos.environ[VersionEnvVars.VALIDATE_BUMP]notin{'false','0'}validate_bump=self.config.get('validate-bump',True)ifnotisinstance(validate_bump,bool):message='option `validate-bump` must be a boolean'raiseTypeError(message)returnvalidate_bump@abstractmethoddefupdate(self,desired_version:str,original_version:str,version_data:dict)->str:""" This should return a normalized form of the desired version. If the [validate_bump](reference.md#hatchling.version.scheme.plugin.interface.VersionSchemeInterface.validate_bump) property is `True`, this method should also verify that the version is higher than the original version. """
This is the value of the validate-bump option, with the HATCH_VERSION_VALIDATE_BUMP environment variable taking precedence. Validation is enabled by default.
This should return a normalized form of the desired version. If the validate_bump property is True, this method should also verify that the version is higher than the original version.
Source code in backend/src/hatchling/version/scheme/plugin/interface.py
@abstractmethoddefupdate(self,desired_version:str,original_version:str,version_data:dict)->str:""" This should return a normalized form of the desired version. If the [validate_bump](reference.md#hatchling.version.scheme.plugin.interface.VersionSchemeInterface.validate_bump) property is `True`, this method should also verify that the version is higher than the original version. """