diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09efb92..173deb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, ubuntu-22.04, macos-12, macos-14] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 diff --git a/argcomplete/packages/_argparse.py b/argcomplete/packages/_argparse.py index d10cf01..10ed00c 100644 --- a/argcomplete/packages/_argparse.py +++ b/argcomplete/packages/_argparse.py @@ -5,6 +5,7 @@ # This file contains argparse introspection utilities used in the course of argcomplete execution. +import sys from argparse import ( ONE_OR_MORE, OPTIONAL, @@ -15,6 +16,7 @@ Action, ArgumentError, ArgumentParser, + Namespace, _get_action_name, _SubParsersAction, ) @@ -75,6 +77,19 @@ class IntrospectiveArgumentParser(ArgumentParser): except for the lines that contain the string "Added by argcomplete". ''' + def _parse_known_args2(self, args, namespace, intermixed): + if args is None: + # args default to the system args + args = sys.argv[1:] + else: + # make sure that args are mutable + args = list(args) + + # default Namespace built from parser defaults + if namespace is None: + namespace = Namespace() + return self._parse_known_args(args, namespace) + def _parse_known_args(self, arg_strings, namespace): _num_consumed_args.clear() # Added by argcomplete self._argcomplete_namespace = namespace