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

cli: fix TypeError in HelpfulArgumentParser for python 3.12.8 and 3.13.1 #15692

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions awxkit/awxkit/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@
self._print_message('\n')
self.exit(2, '%s: %s\n' % (self.prog, message))

def _parse_known_args(self, args, ns):
def _parse_known_args(self, args, ns, intermixed=False):
for arg in ('-h', '--help'):
# the -h argument is extraneous; if you leave it off,
# awx-cli will just print usage info
if arg in args:
args.remove(arg)
return super(HelpfulArgumentParser, self)._parse_known_args(args, ns)

super__parse_known_args = super(HelpfulArgumentParser, self)._parse_known_args
# python <=3.12.7 and ==3.13.0 have an arg count of 3
# python ~=3.12.8 and >=3.13.1 have an arg count of 4
# https://github.com/python/cpython/pull/125356/files#diff-205ef24c9374465bf35c359abce9211d3aa113e986a1e3d41569eb29d07df479R1967
if super__parse_known_args.__code__.co_argcount == 3:
return super__parse_known_args(args, ns)
return super__parse_known_args(args, ns, intermixed)

Check warning on line 56 in awxkit/awxkit/cli/utils.py

View check run for this annotation

Codecov / codecov/patch

awxkit/awxkit/cli/utils.py#L56

Added line #L56 was not covered by tests


def color_enabled():
Expand Down
Loading