Skip to content

Commit

Permalink
Preliminary Python 3.13 compatibility (#513)
Browse files Browse the repository at this point in the history
* Preliminary Python 3.13 compatibility

* CI: add a Python 3.13 job
  • Loading branch information
liushuyu authored Nov 28, 2024
1 parent 252d529 commit bdf34f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions argcomplete/packages/_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,6 +16,7 @@
Action,
ArgumentError,
ArgumentParser,
Namespace,
_get_action_name,
_SubParsersAction,
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bdf34f3

Please sign in to comment.