@invoke.task<EOL>def version(ctx, version=None, force=False):
<EOL>updates = {<EOL>ctx.directory.joinpath("<STR_LIT>"): [<EOL>(r"<STR_LIT>", "<STR_LIT>")<EOL>],<EOL>ctx.package.directory.joinpath("<STR_LIT>"): [<EOL>(r"<STR_LIT>", '<STR_LIT>')<EOL>],<EOL>}<EOL>previous_version = get_previous_version(ctx)<EOL>if isinstance(version, str):<EOL><INDENT>version = parver.Version.parse(version)<EOL>if not force and version <= previous_version:<EOL><INDENT>error_message = (<EOL>f"<STR_LIT>"<EOL>)<EOL>report.error(ctx, "<STR_LIT>", error_message)<EOL>raise ValueError(error_message)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>version = previous_version.bump_release(index=len(previous_version.release) - <NUM_LIT:1>)<EOL><DEDENT>report.info(ctx, "<STR_LIT>", f"<STR_LIT>")<EOL>for (path, replacements) in updates.items():<EOL><INDENT>if path.is_file():<EOL><INDENT>content = path.read_text()<EOL>for (pattern, sub) in replacements:<EOL><INDENT>report.debug(<EOL>ctx,<EOL>"<STR_LIT>",<EOL>f"<STR_LIT>",<EOL>)<EOL>content = re.sub(pattern, sub.format(version=version), content, re.M)<EOL><DEDENT>path.write_text(content)<EOL><DEDENT><DEDENT>
Specify a new version for the package.

    .. important:: If no version is specified, will take the most recent parsable git
        tag and bump the patch number.

    :param str version: The new version of the package.
    :param bool force: If True, skips version check