Skip to content

Commit b295586

Browse files
committed
BooleanOptionalAction
1 parent 15e5ea6 commit b295586

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

scripts/update_lib/auto_mark.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,21 +675,22 @@ def main(argv: list[str] | None = None) -> int:
675675
help="Also add @expectedFailure to failing tests (default: only remove unexpected successes)",
676676
)
677677
parser.add_argument(
678-
"--skip-build",
679-
action="store_true",
680-
help="Skip cargo build, use pre-built binary",
678+
"--build",
679+
action=argparse.BooleanOptionalAction,
680+
default=True,
681+
help="Build with cargo (default: enabled)",
681682
)
682683

683684
args = parser.parse_args(argv)
684685

685686
try:
686687
if args.path.is_dir():
687688
num_added, num_removed, _ = auto_mark_directory(
688-
args.path, mark_failure=args.mark_failure, skip_build=args.skip_build
689+
args.path, mark_failure=args.mark_failure, skip_build=not args.build
689690
)
690691
else:
691692
num_added, num_removed, _ = auto_mark_file(
692-
args.path, mark_failure=args.mark_failure, skip_build=args.skip_build
693+
args.path, mark_failure=args.mark_failure, skip_build=not args.build
693694
)
694695
if args.mark_failure:
695696
print(f"Added expectedFailure to {num_added} tests")

scripts/update_lib/quick.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -271,41 +271,45 @@ def main(argv: list[str] | None = None) -> int:
271271
help="Source path (file or directory)",
272272
)
273273
parser.add_argument(
274-
"--no-copy",
275-
action="store_true",
276-
help="Skip copy-lib step (implied if path is a test path)",
274+
"--copy",
275+
action=argparse.BooleanOptionalAction,
276+
default=True,
277+
help="Copy library file (default: enabled, implied disabled if test path)",
277278
)
278279
parser.add_argument(
279-
"--no-migrate",
280-
action="store_true",
281-
help="Skip migration step (implied if path starts with Lib/)",
280+
"--migrate",
281+
action=argparse.BooleanOptionalAction,
282+
default=True,
283+
help="Migrate test file (default: enabled, implied disabled if Lib/ path)",
282284
)
283285
parser.add_argument(
284-
"--no-auto-mark",
285-
action="store_true",
286-
help="Skip auto-mark step",
286+
"--auto-mark",
287+
action=argparse.BooleanOptionalAction,
288+
default=True,
289+
help="Auto-mark test failures (default: enabled)",
287290
)
288291
parser.add_argument(
289292
"--mark-failure",
290293
action="store_true",
291294
help="Add @expectedFailure to failing tests",
292295
)
293296
parser.add_argument(
294-
"--no-commit",
295-
action="store_true",
296-
help="Skip git commit step",
297+
"--commit",
298+
action=argparse.BooleanOptionalAction,
299+
default=True,
300+
help="Create git commit (default: enabled)",
297301
)
298302
parser.add_argument(
299-
"--skip-build",
300-
action="store_true",
301-
help="Skip cargo build, use pre-built binary",
303+
"--build",
304+
action=argparse.BooleanOptionalAction,
305+
default=True,
306+
help="Build with cargo (default: enabled)",
302307
)
303308

304309
args = parser.parse_args(argv)
305310

306311
try:
307312
src_path = args.path
308-
no_copy = args.no_copy
309313

310314
# Shortcut: expand simple name to cpython/Lib path
311315
src_path = _expand_shortcut(src_path)
@@ -320,7 +324,7 @@ def main(argv: list[str] | None = None) -> int:
320324
# Get library destination path for commit
321325
lib_file_path = parse_lib_path(src_path)
322326

323-
if not no_copy:
327+
if args.copy:
324328
from update_lib.copy_lib import copy_lib
325329

326330
copy_lib(src_path)
@@ -336,14 +340,14 @@ def main(argv: list[str] | None = None) -> int:
336340
# Process the test path
337341
quick(
338342
src_path,
339-
no_migrate=args.no_migrate,
340-
no_auto_mark=args.no_auto_mark,
343+
no_migrate=not args.migrate,
344+
no_auto_mark=not args.auto_mark,
341345
mark_failure=args.mark_failure,
342-
skip_build=args.skip_build,
346+
skip_build=not args.build,
343347
)
344348

345349
# Step 3: Git commit
346-
if not args.no_commit:
350+
if args.commit:
347351
# Extract module name from path
348352
name = original_src.stem
349353
if name == "__init__":

0 commit comments

Comments
 (0)