Skip to content

Cannot invoke task with underscore in method name #1055

Open

Description

@dax-westerman

Version: 2.2.1

Use Case

Using the example tasks.py...

from invoke.tasks import task


@task
def show_help(c):
    """Show available tasks."""
    print("Available tasks:")
    
@task
def showhelp(c):
    """Show available tasks."""
    print("Available tasks:")

Calling showhelp...

invoke showhelp

prints

Available tasks:

however, calling 'show_help`...

invoke show_help

results in

No idea what 'show_help' is!

Activity

  1. OttoAndrey commented on Dec 5, 2025

    @OttoAndrey

    hi! You can see available tasks/commands by

    inv -l

    and maybe you need call it like

    inv show-help
  2. jbbqqf commented on May 24, 2026

    @jbbqqf

    Hi @dax-westerman — drive-by triage: I believe this is working as designed.

    Invoke ships with tasks.auto_dash_names: True as a default (invoke/config.py), which means a Python task named show_help is exposed on the CLI as show-help (dashes), not show_help (underscores). So:

    invoke show-help    # works
    invoke show_help    # not found — this is expected

    The behavior is documented in sites/docs/concepts/invoking-tasks.rst under "Dashes vs underscores in flag names", and the toggle is described in sites/docs/concepts/namespaces.rst (set tasks.auto_dash_names: false in invoke.yaml to opt out). @OttoAndrey already pointed this out in their reply.

    Probably safe to close. Happy to be corrected if there's a separate bug here I'm missing.


    Drive-by triage from an outside contributor (data engineer GCP/Python, jbbqqf). Comment drafted with Claude assistance; evidence and conclusion are mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions