aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2025-10-18 17:17:20 +0100
committerGravatar Joe Banks <[email protected]>2025-10-18 21:20:00 +0100
commit3711f929ea4726289f3363fc31718e8a820f7974 (patch)
tree9ea4ca690f8e9d8728085ebdb36097827459f912
parentAdd local registry for sharing between buildx jobs (diff)
Update argparse usage to support 3.14
Our usage of store_const with positionals is now unsupported and gives a ValueError on 3.14, this change maintains the same behaviour (splitting based on --- to fill nsjail_args and py_args)
-rw-r--r--snekbox/__main__.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/snekbox/__main__.py b/snekbox/__main__.py
index 1e5bcec..dbc2ab6 100644
--- a/snekbox/__main__.py
+++ b/snekbox/__main__.py
@@ -13,18 +13,19 @@ def parse_args() -> argparse.Namespace:
)
parser.add_argument("code", help="the Python code to evaluate")
parser.add_argument(
- "nsjail_args",
- action="store_const",
- const=[],
+ "--nsjail-args",
+ nargs="*",
+ default=[],
+ dest="nsjail_args",
help="override configured NsJail options (default: [])",
)
parser.add_argument(
- "py_args",
- action="store_const",
- const=["-c"],
+ "--py-args",
+ nargs="*",
+ default=["-c"],
+ dest="py_args",
help="arguments to pass to the Python process (default: ['-c'])",
)
-
# nsjail_args and py_args are just dummies for documentation purposes.
# Their actual values come from all the unknown arguments.
# There doesn't seem to be a better solution with argparse.