Skip to content

Commit

Permalink
fix: ErrorArgumentParser override of _parse_known_args is incompatibl…
Browse files Browse the repository at this point in the history
…e with 3.12.7

Fixes #3264

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Nov 9, 2024
1 parent 88d947f commit d3d29f4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions news/3264.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix compatibility of `ErrorArgumentParser` for Python 3.12 and above.
4 changes: 2 additions & 2 deletions src/pdm/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ class ErrorArgumentParser(ArgumentParser):
"""

def _parse_known_args(
self, arg_strings: list[str], namespace: argparse.Namespace
self, arg_strings: list[str], namespace: argparse.Namespace, *args: Any, **kwargs: Any
) -> tuple[argparse.Namespace, list[str]]:
try:
return super()._parse_known_args(arg_strings, namespace)
return super()._parse_known_args(arg_strings, namespace, *args, **kwargs)
except argparse.ArgumentError as e:
# We raise a dedicated error to avoid being caught by the caller
raise PdmArgumentError(e) from e
Expand Down

0 comments on commit d3d29f4

Please sign in to comment.