Skip to content

Commit 8e5ab06

Browse files
committed
Improve error message for missing required arguments
:wq#
1 parent 716bbc2 commit 8e5ab06

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

fire/core.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,18 @@ def _CallAndUpdateTrace(component, args, component_trace, treatment='class',
687687
# Event loop is already running
688688
component = loop.run_until_complete(fn(*varargs, **kwargs))
689689
else:
690-
component = fn(*varargs, **kwargs)
690+
try:
691+
component = fn(*varargs, **kwargs)
692+
except TypeError as e:
693+
message = str(e)
694+
695+
if 'missing' in message and 'required positional argument' in message:
696+
raise TypeError(
697+
f"Error: {message}\n\n"
698+
f"Hint: Run the command with --help to see usage."
699+
) from None
700+
701+
raise
691702

692703
if treatment == 'class':
693704
action = trace.INSTANTIATED_CLASS

0 commit comments

Comments
 (0)