def update_version(new_version: str, dry_run: bool) -> None:
    """Update the version in the giving py version file."""
    version_file_path = ROOT_DIR / PACKAGE_VERSION_FILE
    with open(version_file_path, encoding='utf8') as f:
        content = f.read()

    # Regex to match the VERSION assignment
    pattern = r'(VERSION\s*=\s*)([\'\"])([^\"^\']+)([\'\"])'
    version_stm = re.search(pattern, content)
    if not version_stm:
        print(
            'Could not find the version assignment in the version file.'
            'Please make sure the version file has a line like `VERSION = "1.2.3"`.'
        )
        sys.exit(1)
    old_version = version_stm.group(3)
    if old_version == new_version:
        warnings.warn('The new version is the same as the old version. The script might not have any effect.')
    old_version_stm = ''.join(version_stm.groups())
    new_version_stm = old_version_stm.replace(old_version, new_version)

    if dry_run:
        print(f'Updating version in version file at "{PACKAGE_VERSION_FILE}"')
        print('--- Before ---')
        print(old_version_stm)
        print('--- After ---')
        print(new_version_stm)
        print('Running in dry mode, lock file is not updated.')
        return
    with open(version_file_path, 'w', encoding='utf8') as f:
        new_content = content.replace(old_version_stm, new_version_stm)
        f.write(new_content)
    run_command('uv', 'lock', '-P', 'pydantic')
Update the version in the giving py version file.
release/prepare.py