quickie.factories.task
- quickie.factories.task(fn: Callable) type[Task]
- quickie.factories.task(*, name: str | None = None, extra_args: bool | None = None, bind: bool = False, condition: BaseCondition | None = None, before: Sequence[Any] | None = None, after: Sequence[Any] | None = None, cleanup: Sequence[Any] | None = None) PartialReturnType[Task]
Create a task from a function.
@task(name="hello", bind=True) def hello_task(task): task.console.print("Hello, task!") @task def hello_world(): """Docstring will be used as help text.""" print("Hello, world!")
- Parameters:
fn – The function to create the task from.
name – The name of the task.
extra_args – If the task accepts extra arguments.
bind – If true, the first parameter of the function will be the task class instance.
condition – The condition to check before running the task.
before – The tasks to run before the task.
after – The tasks to run after the task.
cleanup – The tasks to run after the task, even if it fails.
- Returns:
The task class, or, if fn is None, a partial function to be used as a decorator for a function.