Skip to content

Fix #562: default task missing positionals raises ParseError - #1082

Open
DSeaStar wants to merge 1 commit into
pyinvoke:mainfrom
DSeaStar:fix-562-default-task-missing-positionals
Open

Fix #562: default task missing positionals raises ParseError#1082
DSeaStar wants to merge 1 commit into
pyinvoke:mainfrom
DSeaStar:fix-562-default-task-missing-positionals

Conversation

@DSeaStar

Copy link
Copy Markdown

Summary

  • When a collection has a default task and no task name is given, Executor.normalize used to call that task with no arguments. Required positionals then failed inside the task body as a TypeError traceback (custom Program binaries, or inv with no argv).
  • The default-task path now checks the same required-positional rules as the parser and raises ParseError, so Program.run prints the familiar 'task' did not receive required positional arguments: 'arg' message and exits 1.
  • Adds unit/CLI tests for the missing-arg case and for a default task that only has optional arguments.

Fixes #562.

Test plan

  • Executor.execute() with a default task missing a required positional raises ParseError (not TypeError)
  • Program.run("myapp") with that collection prints the parser-style error on stderr
  • Default task with only optional args still runs
  • Existing default_tasks_called_when_no_tasks_specified (Mock body / *args, **kwargs) still passes
  • Named-task missing positionals still uses the original parser error path

The default-task fallback skipped the parser, so a custom Program (or
inv with no argv) leaked a traceback instead of the usual ParseError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom binary + default task + missing arguments gives traceback

1 participant