def replace_version(search_dir: Path = _DEFAULT_SEARCH_DIR, *, old: str, new: str):
    """Replaces the current version number with a new version number.

    Args:
        search_dir: the search directory for modules.
        old: the current version number.
        new: the new version number.
    Raises:
        ValueError: if `old` does not match the current version, or if there is not exactly one
            version number in the found modules.
    """
    version = get_version(search_dir=search_dir)
    if version != old:
        raise ValueError(f"{old} does not match current version: {version}")

    _validate_version(new)

    for m in list_modules(search_dir=search_dir, include_parent=True):
        version_file = _find_version_file(search_dir / m.root)
        _rewrite_version(version_file, old, new)
        version_test = version_file.parent / "_version_test.py"
        _rewrite_version(version_test, old, new)
Replaces the current version number with a new version number.

    Args:
        search_dir: the search directory for modules.
        old: the current version number.
        new: the new version number.
    Raises:
        ValueError: if `old` does not match the current version, or if there is not exactly one
            version number in the found modules.
    
dev_tools/modules.py