You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are deep in Argparser territory here. The strings are printed by the exit
method form the ArgumentParser class. The logic that raises this is in the
internal _get_value methode:
def_get_value(self, action, arg_string):
type_func=self._registry_get('type', action.type, action.type)
ifnot_callable(type_func):
msg=_('%r is not callable')
raiseArgumentError(action, msg%type_func)
# convert the value to the appropriate typetry:
result=type_func(arg_string)
# ArgumentTypeErrors indicate errorsexceptArgumentTypeError:
name=getattr(action.type, '__name__', repr(action.type))
msg=str(_sys.exc_info()[1])
raiseArgumentError(action, msg)
# TypeErrors or ValueErrors also indicate errorsexcept (TypeError, ValueError):
name=getattr(action.type, '__name__', repr(action.type))
msg=_('invalid %s value: %r')
raiseArgumentError(action, msg% (name, arg_string))
One workaround could be to subclass the ArgumentParser class and override its error method, to raise errors as exception instead of printing and exiting, so that we could handle the output ourself and restrict it for no_echo options:
The text was updated successfully, but these errors were encountered: