Long tasks name make `invoke --list | grep a` crash with "invalid width"
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start in invoke/program.py at list_tasks, list_flat, display_with_columns, and print_columns, following the traceback from invoke --list | grep a. Reproduce the long task name case and inspect how the available terminal width reaches textwrap. Done means the command no longer raises ValueError: invalid width 0 and still displays the task list.
Written by the indexing model from the issue text.
Description
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)
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 412
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pyinvoke/invoke
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100