Transform argparse error message into UsageError.
(self, message: str)
| 404 | self.extra_info = extra_info if extra_info else {} |
| 405 | |
| 406 | def error(self, message: str) -> "NoReturn": |
| 407 | """Transform argparse error message into UsageError.""" |
| 408 | msg = f"{self.prog}: error: {message}" |
| 409 | |
| 410 | if hasattr(self._parser, "_config_source_hint"): |
| 411 | # Type ignored because the attribute is set dynamically. |
| 412 | msg = f"{msg} ({self._parser._config_source_hint})" # type: ignore |
| 413 | |
| 414 | raise UsageError(self.format_usage() + msg) |
| 415 | |
| 416 | # Type ignored because typeshed has a very complex type in the superclass. |
| 417 | def parse_args( # type: ignore |
no test coverage detected