Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preliminary Python 3.13 compatibility #513

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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