X Tutup
Skip to content

Commit fd0bc1b

Browse files
committed
BooleanOptionalAction
1 parent 6438fce commit fd0bc1b

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
@@ -272,41 +272,45 @@ def main(argv: list[str] | None = None) -> int:
272272
help="Source path (file or directory)",
273273
)
274274
parser.add_argument(
275-
"--no-copy",
276-
action="store_true",
277-
help="Skip copy-lib step (implied if path is a test path)",
275+
"--copy",
276+
action=argparse.BooleanOptionalAction,
277+
default=True,
278+
help="Copy library file (default: enabled, implied disabled if test path)",
278279
)
279280
parser.add_argument(
280-
"--no-migrate",
281-
action="store_true",
282-
help="Skip migration step (implied if path starts with Lib/)",
281+
"--migrate",
282+
action=argparse.BooleanOptionalAction,
283+
default=True,
284+
help="Migrate test file (default: enabled, implied disabled if Lib/ path)",
283285
)
284286
parser.add_argument(
285-
"--no-auto-mark",
286-
action="store_true",
287-
help="Skip auto-mark step",
287+
"--auto-mark",
288+
action=argparse.BooleanOptionalAction,
289+
default=True,
290+
help="Auto-mark test failures (default: enabled)",
288291
)
289292
parser.add_argument(
290293
"--mark-failure",
291294
action="store_true",
292295
help="Add @expectedFailure to failing tests",
293296
)
294297
parser.add_argument(
295-
"--no-commit",
296-
action="store_true",
297-
help="Skip git commit step",
298+
"--commit",
299+
action=argparse.BooleanOptionalAction,
300+
default=True,
301+
help="Create git commit (default: enabled)",
298302
)
299303
parser.add_argument(
300-
"--skip-build",
301-
action="store_true",
302-
help="Skip cargo build, use pre-built binary",
304+
"--build",
305+
action=argparse.BooleanOptionalAction,
306+
default=True,
307+
help="Build with cargo (default: enabled)",
303308
)
304309

305310
args = parser.parse_args(argv)
306311

307312
try:
308313
src_path = args.path
309-
no_copy = args.no_copy
310314

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

324-
if not no_copy:
328+
if args.copy:
325329
from update_lib.copy_lib import copy_lib
326330

327331
copy_lib(src_path)
@@ -337,14 +341,14 @@ def main(argv: list[str] | None = None) -> int:
337341
# Process the test path
338342
quick(
339343
src_path,
340-
no_migrate=args.no_migrate,
341-
no_auto_mark=args.no_auto_mark,
344+
no_migrate=not args.migrate,
345+
no_auto_mark=not args.auto_mark,
342346
mark_failure=args.mark_failure,
343-
skip_build=args.skip_build,
347+
skip_build=not args.build,
344348
)
345349

346350
# Step 3: Git commit
347-
if not args.no_commit:
351+
if args.commit:
348352
# Extract module name from path
349353
name = original_src.stem
350354
if name == "__init__":

0 commit comments

Comments
 (0)
X Tutup