Skip to content

bumpversion.config.files ​

Contains methods for finding and reading configuration files.

logger ​

python
logger = get_indented_logger(__name__)

CONFIG_FILE_SEARCH_ORDER ​

python
CONFIG_FILE_SEARCH_ORDER = ('.bumpversion.cfg', '.bumpversion.toml', 'setup.cfg', 'pyproject.toml')

get_pep621_info ​

python
def get_pep621_info(config_file: Optional[Pathlike] = None) -> Optional[PEP621Info]

Retrieve the PEP 621 project table.

At the moment, only the project.version key is handled. Additionally, if the version is marked as dynamic, then it is explicitly returned as None.

Parameters

  • config_file: The configuration file to explicitly use. Per PEP 621, this file must be named pyproject.toml.

Returns

  • A PEP621Info structure, if given a pyproject.toml file to parse, else None.

find_config_file ​

python
def find_config_file(explicit_file: Optional[Pathlike] = None) -> Union[Path, None]

Find the configuration file if it exists.

If no explicit configuration file is passed, it will search in several files to find its configuration.

Parameters

  • explicit_file: The configuration file to explicitly use.

Returns

  • The configuration file path

read_config_file ​

python
def read_config_file(config_file: Optional[Pathlike] = None) -> Dict[str, Any]

Read the configuration file if it exists.

If no explicit configuration file is passed, it will search in several files to find its configuration.

Parameters

  • config_file: The configuration file to explicitly use.

Returns

  • A dictionary of read key-values

read_toml_file ​

python
def read_toml_file(file_path: Path) -> Dict[str, Any]

Parse a TOML file and return the bumpversion section.

Parameters

  • file_path: The path to the TOML file.

Returns

  • A dictionary of the bumpversion section.

update_config_file ​

python
def update_config_file(config_file: Union[str, Path], config: Config, current_version: Version, new_version: Version, context: MutableMapping, dry_run: bool = False) -> None

Update the current_version key in the configuration file.

Parameters

  • config_file: The configuration file to explicitly use.
  • config: The configuration to use.
  • current_version: The current version.
  • new_version: The new version.
  • context: The context to use for serialization.
  • dry_run: True if the update should be a dry run.