Skip to content

myke.task

Functions for registering tasks with myke.

Functions

add_tasks

add_tasks(
    *args: Union[Callable[..., Any], Task],
    **kwargs: Callable[..., Any]
) -> None

Register the given callable(s) with myke.

PARAMETER DESCRIPTION
*args

...

TYPE: Union[Callable[..., Any], Task] DEFAULT: ()

**kwargs

...

TYPE: Callable[..., Any] DEFAULT: {}

RAISES DESCRIPTION
TaskAlreadyRegisteredError

...

Examples:

import myke


def say_hello(name):
    print(f"Hello {name}.")


def say_goodbye(name):
    print(f"Goodbye {name}.")


myke.add_tasks(say_hello, say_goodbye)

import_module

import_module(name: str) -> None

Import tasks from the given Python module.

PARAMETER DESCRIPTION
name

name of the module.

TYPE: str

RAISES DESCRIPTION
NoTasksFoundError

Examples:

# import myke

# myke.import_module("python_pkg.python_module")

import_mykefile

import_mykefile(path: Union[str, Path]) -> None

Import tasks from another Mykefile.

PARAMETER DESCRIPTION
path

path to the Mykefile

TYPE: Union[str, Path]

RAISES DESCRIPTION
NoTasksFoundError

Examples:

# import myke

# myke.import_mykefile("/path/to/tasks.py")

task

task(
    func: Union[Callable[..., Any], None] = None,
    *,
    name: Union[str, None] = None,
    parents: Union[
        str, tuple[Union[str, Command], ...], None
    ] = None
) -> Union[
    Callable[..., Any], Callable[..., Callable[..., Any]]
]

Function decorator to register functions with myke.

PARAMETER DESCRIPTION
func

...

TYPE: Union[Callable[..., Any], None] DEFAULT: None

name

name of the command.

TYPE: Union[str, None] DEFAULT: None

parents

optional parent(s) for the command.

TYPE: Union[str, tuple[Union[str, Command], ...], None] DEFAULT: None

RETURNS DESCRIPTION
Union[Callable[..., Any], Callable[..., Callable[..., Any]]]

...

Examples:

from myke import task


@task
def say_hello(name):
    print(f"Hello {name}.")


@task
def say_goodbye(name):
    print(f"Goodbye {name}.")