Allow splitting of positional arguments.
( # type: ignore
self,
args: Optional[Sequence[str]] = None,
namespace: Optional[argparse.Namespace] = None,
)
| 415 | |
| 416 | # Type ignored because typeshed has a very complex type in the superclass. |
| 417 | def parse_args( # type: ignore |
| 418 | self, |
| 419 | args: Optional[Sequence[str]] = None, |
| 420 | namespace: Optional[argparse.Namespace] = None, |
| 421 | ) -> argparse.Namespace: |
| 422 | """Allow splitting of positional arguments.""" |
| 423 | parsed, unrecognized = self.parse_known_args(args, namespace) |
| 424 | if unrecognized: |
| 425 | for arg in unrecognized: |
| 426 | if arg and arg[0] == "-": |
| 427 | lines = ["unrecognized arguments: %s" % (" ".join(unrecognized))] |
| 428 | for k, v in sorted(self.extra_info.items()): |
| 429 | lines.append(f" {k}: {v}") |
| 430 | self.error("\n".join(lines)) |
| 431 | getattr(parsed, FILE_OR_DIR).extend(unrecognized) |
| 432 | return parsed |
| 433 | |
| 434 | if sys.version_info[:2] < (3, 9): # pragma: no cover |
| 435 | # Backport of https://github.com/python/cpython/pull/14316 so we can |