From 6f18cdff6cc5cbf07e6f20c174106d81c50527ce Mon Sep 17 00:00:00 2001 From: Tyler Mace Date: Wed, 28 May 2025 14:39:10 -0700 Subject: [PATCH] Suggest invoke is more polite with errors. --- invoke/collection.py | 2 +- invoke/parser/parser.py | 2 +- invoke/program.py | 2 +- sites/docs/concepts/library.rst | 2 +- tests/program.py | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/invoke/collection.py b/invoke/collection.py index 23dcff928..fc41b1ae5 100644 --- a/invoke/collection.py +++ b/invoke/collection.py @@ -120,7 +120,7 @@ def _add_object(self, obj: Any, name: Optional[str] = None) -> None: elif isinstance(obj, (Collection, ModuleType)): method = self.add_collection else: - raise TypeError("No idea how to insert {!r}!".format(type(obj))) + raise TypeError("Unknown how to insert {!r}.".format(type(obj))) method(obj, name=name) def __repr__(self) -> str: diff --git a/invoke/parser/parser.py b/invoke/parser/parser.py index 43e95df04..4159b367f 100644 --- a/invoke/parser/parser.py +++ b/invoke/parser/parser.py @@ -322,7 +322,7 @@ def handle(self, token: str) -> None: else: if not self.ignore_unknown: debug("Can't find context named {!r}, erroring".format(token)) - self.error("No idea what {!r} is!".format(token)) + self.error("Unknown what {!r} is.".format(token)) else: debug("Bottom-of-handle() see_unknown({!r})".format(token)) self.see_unknown(token) diff --git a/invoke/program.py b/invoke/program.py index c7e5cd004..a29f60f12 100644 --- a/invoke/program.py +++ b/invoke/program.py @@ -511,7 +511,7 @@ def parse_cleanup(self) -> None: else: # TODO: feels real dumb to factor this out of Parser, but...we # should? - raise ParseError("No idea what '{}' is!".format(halp)) + raise ParseError("Unknown what '{}' is.".format(halp)) # Print discovered tasks if necessary list_root = self.args.list.value # will be True or string diff --git a/sites/docs/concepts/library.rst b/sites/docs/concepts/library.rst index 1eeb55375..4e3500309 100644 --- a/sites/docs/concepts/library.rst +++ b/sites/docs/concepts/library.rst @@ -140,7 +140,7 @@ The result? integration $ tester --list - No idea what '--list' is! + Unknown what '--list' is. $ tester unit Running unit tests! diff --git a/tests/program.py b/tests/program.py index 2d249b1fb..e115953cc 100644 --- a/tests/program.py +++ b/tests/program.py @@ -360,7 +360,7 @@ def seeks_and_loads_tasks_module_by_default(self): def does_not_seek_tasks_module_if_namespace_was_given(self): expect( "foo", - err="No idea what 'foo' is!\n", + err="Unknown what 'foo' is.\n", program=Program(namespace=Collection("blank")), ) @@ -402,7 +402,7 @@ def ParseErrors_display_message_and_exit_1(self, mock_exit): # "no idea what foo is!") and exit 1. (Intent is to display that # info w/o a full traceback, basically.) stderr = sys.stderr.getvalue() - assert stderr == "No idea what '{}' is!\n".format(nah) + assert stderr == "Unknown what '{}' is.\n".format(nah) mock_exit.assert_called_with(1) @trap @@ -736,7 +736,7 @@ def exits_after_printing(self): expect("-c decorators -h punch --list", out=expected) def complains_if_given_invalid_task_name(self): - expect("-h this", err="No idea what 'this' is!\n") + expect("-h this", err="Unknown what 'this' is.\n") class task_list: "--list"