Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP/suggestion]: Make no-idea errors more kind/empathetic #1010

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion invoke/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("Cannot insert {!r}.".format(type(obj)))
method(obj, name=name)

def __repr__(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion invoke/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("Flag {!r} not recognised".format(token))
else:
debug("Bottom-of-handle() see_unknown({!r})".format(token))
self.see_unknown(token)
Expand Down
2 changes: 1 addition & 1 deletion invoke/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("'{}' command not recognised.".format(halp))

# Print discovered tasks if necessary
list_root = self.args.list.value # will be True or string
Expand Down
2 changes: 1 addition & 1 deletion sites/docs/concepts/library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The result?
integration

$ tester --list
No idea what '--list' is!
Command '--list' not recognised.
$ tester unit
Running unit tests!

Expand Down
8 changes: 4 additions & 4 deletions tests/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="Task 'foo' not recognised.",
program=Program(namespace=Collection("blank")),
)

Expand Down Expand Up @@ -399,10 +399,10 @@ def ParseErrors_display_message_and_exit_1(self, mock_exit):
nah = "nopenotvalidsorry"
p.run("myapp {}".format(nah))
# Expect that we did print the core body of the ParseError (e.g.
# "no idea what foo is!") and exit 1. (Intent is to display that
# "Command 'foo' not recognised.") 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 == "Command '{}' not recognised.\n".format(nah)
mock_exit.assert_called_with(1)

@trap
Expand Down Expand Up @@ -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="Task 'this' not recognised.\n")

class task_list:
"--list"
Expand Down