Greg Wilson
Greg Wilson

Reputation: 1363

how to get pydoit to run all cmd-action tasks even if some have non-zero exit status?

I would like to run all tasks even if some have non-zero exit status. I can do this with doit --continue from the command line, but would like to embed the directive in the dodo.py file itself. I've checked the docs but have been unable to find a way - my starting point is:

def task_lint():
    """Run checks on code."""
    return {
        "actions": [
            "pflake8",
            "isort --check .",
            "black --check ."
        ]
    }

In Make I would prefix commands with -:

check:
        -flake8
        -isort --check .
        -black --check .

What should I do in doit?

Upvotes: 1

Views: 693

Answers (1)

schettino72
schettino72

Reputation: 3170

DOIT_CONFIG = {
    "continue": True,
}


def task_lint():
    """Run checks on code."""
    yield {
        "name": "flake8",
        "actions": ["flake8"],
    }

    yield {
        "name": "isort",
        "actions": ["isort --check ."],
    }

    yield {
        "name": "black",
        "actions": ["black  --check ."],
    }

Notes:

  1. --continue is for tasks, not actions. Your example is better written as 3 separate tasks. That also allows you to execute them individually (doit lint:flake8).

  2. use DOIT_CONFIG to pass configuration (could also be done on INI or TOML files). Notice that doit help run command will display the config name to be used.

Upvotes: 1

Related Questions