Skip to content

Commit a887b3c

Browse files
committed
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)
1 parent fd93b9e commit a887b3c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

snekbox/__main__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ def parse_args() -> argparse.Namespace:
1313
)
1414
parser.add_argument("code", help="the Python code to evaluate")
1515
parser.add_argument(
16-
"nsjail_args",
17-
action="store_const",
18-
const=[],
16+
"--nsjail-args",
17+
nargs="*",
18+
default=[],
19+
dest="nsjail_args",
1920
help="override configured NsJail options (default: [])",
2021
)
2122
parser.add_argument(
22-
"py_args",
23-
action="store_const",
24-
const=["-c"],
23+
"--py-args",
24+
nargs="*",
25+
default=["-c"],
26+
dest="py_args",
2527
help="arguments to pass to the Python process (default: ['-c'])",
2628
)
27-
2829
# nsjail_args and py_args are just dummies for documentation purposes.
2930
# Their actual values come from all the unknown arguments.
3031
# There doesn't seem to be a better solution with argparse.

0 commit comments

Comments
 (0)