Skip to content

Long tasks name make invoke --list | grep a crash with "invalid width" #1071

Description

@dbellavista-ai

Sample code:

from invoke.tasks import task

@task
def my_very_long_task_name_that_is_completely_legit_but_make_grep_crash_aaaaaa(c):
    print('Here')

Run wihtout grep:

$ uv run invoke --list
Available tasks:

  my-very-long-task-name-that-is-completely-legit-but-make-grep-crash-aaaaaa

Run with grep:

$ uv run invoke --list | grep a
Traceback (most recent call last):
  File "/my/project/.venv/bin/invoke", line 10, in <module>
Available tasks:
    sys.exit(program.run())
             ^^^^^^^^^^^^^
  File "/my/project/.venv/lib/python3.12/site-packages/invoke/program.py", line 391, in run
    self.parse_cleanup()
  File "/my/project/.venv/lib/python3.12/site-packages/invoke/program.py", line 530, in parse_cleanup
    self.list_tasks()
  File "/my/project/.venv/lib/python3.12/site-packages/invoke/program.py", line 815, in list_tasks
    getattr(self, "list_{}".format(self.list_format))()
  File "/my/project/.venv/lib/python3.12/site-packages/invoke/program.py", line 819, in list_flat
    self.display_with_columns(pairs=pairs)
  File "/my/project/.venv/lib/python3.12/site-packages/invoke/program.py", line 932, in display_with_columns
    self.print_columns(pairs)
  File "/my/project/.venv/lib/python3.12/site-packages/invoke/program.py", line 969, in print_columns
    help_chunks = wrapper.wrap(help_str)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/my/project/.share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/textwrap.py", line 360, in wrap
    return self._wrap_chunks(chunks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/my/project/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/textwrap.py", line 254, in _wrap_chunks
    raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width 0 (must be > 0)

System info:

invoke 3.0.3
Python 3.12.11 (on darwin)

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