Skip to content

Commit

Permalink
cli: fix TypeError in HelpfulArgumentParser for python 3.13.1 (re…
Browse files Browse the repository at this point in the history
…lated ansible#15687)
  • Loading branch information
mhassan1 committed Dec 6, 2024
1 parent 1a35775 commit 9a43b67
Showing 1 changed file with 9 additions and 2 deletions.
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 @@ def error(self, message): # pragma: nocover
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.13.0 and below have an arg count of 3
# python 3.13.1 and above 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)


def color_enabled():
Expand Down

0 comments on commit 9a43b67

Please sign in to comment.