MCPcopy Index your code
hub / github.com/python/cpython / error

Method error

Lib/argparse.py:2875–2891  ·  view source on GitHub ↗

error(message: string) Prints a usage message incorporating the message to stderr and exits. If you override this in a subclass, it should not return -- it should either exit or raise an exception.

(self, message)

Source from the content-addressed store, hash-verified

2873 _sys.exit(status)
2874
2875 def error(self, message):
2876 """error(message: string)
2877
2878 Prints a usage message incorporating the message to stderr and
2879 exits.
2880
2881 If you override this in a subclass, it should not return -- it
2882 should either exit or raise an exception.
2883 """
2884 self.print_usage(_sys.stderr)
2885 theme = self._get_theme(file=_sys.stderr)
2886 fmt = _('%(prog)s: error: %(message)s\n')
2887 fmt = fmt.replace('error: %(message)s',
2888 f'{theme.error}error:{theme.reset} {theme.message}%(message)s{theme.reset}')
2889
2890 args = {'prog': self.prog, 'message': message}
2891 self.exit(2, fmt % args)
2892
2893 def _warning(self, message):
2894 theme = self._get_theme(file=_sys.stderr)

Callers 12

mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
parse_argsMethod · 0.95
_parse_known_args2Method · 0.95
parse_intermixed_argsMethod · 0.95
parse_argsFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
_mainFunction · 0.95
_mainFunction · 0.95

Calls 5

print_usageMethod · 0.95
_get_themeMethod · 0.95
exitMethod · 0.95
_Function · 0.50
replaceMethod · 0.45

Tested by

no test coverage detected