Skip to content

kraken.std.util

kraken.std.util

General utility tasks.

check_and_format_copyright(
    holder: str,
    name: str = "copyright",
    project: Project | None = None,
    ignore: Sequence[str] = (),
    custom_license: str | None = None,
    custom_license_file: Path | None = None,
) -> CopyrightTasks

Creates two copyright tasks, one to check and another to format. The check task will be grouped under "lint" whereas the format task will be grouped under "fmt".

Source code in kraken/std/util/copyright_task.py
def check_and_format_copyright(
    holder: str,
    name: str = "copyright",
    project: Project | None = None,
    ignore: Sequence[str] = (),
    custom_license: str | None = None,
    custom_license_file: Path | None = None,
) -> CopyrightTasks:
    """Creates two copyright tasks, one to check and another to format. The check task will be grouped under `"lint"`
    whereas the format task will be grouped under `"fmt"`."""

    project = project or Project.current()
    check_task = project.task(f"{name}.check", CopyrightTask, group="lint")
    check_task.check_only = True
    check_task.holder = holder
    check_task.ignore = ignore
    check_task.custom_license = custom_license
    check_task.custom_license_file = custom_license_file

    format_task = project.task(f"{name}.fmt", CopyrightTask, group="fmt")
    format_task.check_only = False
    format_task.holder = holder
    format_task.ignore = ignore
    format_task.custom_license = custom_license
    format_task.custom_license_file = custom_license_file

    return CopyrightTasks(check_task, format_task)