Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7c0a8fe
Base version of automated test marker
ShaharNaveh Aug 11, 2025
69ed76b
Remove debug code
ShaharNaveh Aug 11, 2025
dc3a6de
Add newline
ShaharNaveh Aug 11, 2025
5c09ef0
Apply RustPython patch
ShaharNaveh Aug 11, 2025
ad061b2
Convert to tool with args
ShaharNaveh Aug 20, 2025
a6f2324
Apply patch
ShaharNaveh Aug 22, 2025
302b3d1
Remove old script
ShaharNaveh Aug 22, 2025
db74d2f
Add textwrap.py
ShaharNaveh Aug 22, 2025
11694e3
ruff fmt
ShaharNaveh Aug 22, 2025
d8b4e26
Add more modules
ShaharNaveh Aug 22, 2025
2308a5a
Merge remote-tracking branch 'upstream/main' into auto-updater
ShaharNaveh Aug 25, 2025
2fb6842
Add `gen` subcommand
ShaharNaveh Aug 29, 2025
db5eb4b
Use `_generate_next_value_`
ShaharNaveh Aug 29, 2025
af1c28d
Gen & patch
ShaharNaveh Aug 30, 2025
42365d2
Remove old tool
ShaharNaveh Aug 30, 2025
fdce40b
Merge remote-tracking branch 'upstream/main' into auto-updater
ShaharNaveh Aug 30, 2025
32baa80
Revert changes under `Lib/`
ShaharNaveh Aug 30, 2025
fb7324d
Don't crash if cls renamed/moved
ShaharNaveh Aug 30, 2025
f4056ac
Update `Lib/test/test_os.py` with tool
ShaharNaveh Aug 30, 2025
4296b59
apply patch
ShaharNaveh Aug 30, 2025
e2aa220
Fix double assignment
ShaharNaveh Aug 30, 2025
74b47a0
Better args
ShaharNaveh Aug 30, 2025
51c6ad9
Update `test_list.py` as well
ShaharNaveh Aug 30, 2025
01a90ef
Less complex print
ShaharNaveh Aug 30, 2025
a0e56ae
Improve exoectedFailure match
ShaharNaveh Aug 30, 2025
43a63a8
fix list slice
ShaharNaveh Aug 30, 2025
3e2c1f1
Add __doc__ and to help
ShaharNaveh Sep 2, 2025
789cf6e
Merge remote-tracking branch 'upstream/main' into auto-updater
ShaharNaveh Sep 2, 2025
3e9872c
Update scripts/lib_updater.py
ShaharNaveh Sep 4, 2025
d0763e4
Clearer output arg
ShaharNaveh Sep 5, 2025
e00bb28
Don't crash on missing id
ShaharNaveh Sep 5, 2025
8a5875e
Merge remote-tracking branch 'upstream/main' into auto-updater
ShaharNaveh Sep 5, 2025
6c615cc
Merge remote-tracking branch 'origin/auto-updater' into auto-updater
ShaharNaveh Sep 5, 2025
c0e90cc
Fix comment regex
ShaharNaveh Sep 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better args
  • Loading branch information
ShaharNaveh committed Aug 30, 2025
commit 74b47a0e679d5c7c56f35c21b17fbfb395c52389
50 changes: 25 additions & 25 deletions scripts/lib_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def iter_patch_entires(

match ut_method:
case UtMethod.ExpectedFailure:
for line in lines[dec_node.lineno - 2 : dec_node.lineno]:
for line in lines[dec_node.lineno - 2 : dec_node.lineno + 1]:
if COMMENT not in line:
continue
reason = "".join(re.findall(rf"{COMMENT} (.*)", line))
Expand Down Expand Up @@ -231,32 +231,31 @@ def build_argparse() -> argparse.ArgumentParser:
description="Helper tool for updating files under Lib/"
)

parser.add_argument(
"orig_file", help="File to gather patches from", type=pathlib.Path
patches_group = parser.add_mutually_exclusive_group(required=True)
patches_group.add_argument(
"-p",
"--patches",
help="File path to file containing patches in a JSON format",
type=pathlib.Path,
)
patches_group.add_argument(
"--from",
help="File to gather patches from",
dest="gather_from",
type=pathlib.Path,
)

group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"remote_file",
nargs="?",
"--to",
help="File to apply patches to",
type=pathlib.Path,
)
group.add_argument(
"--show-patches", action="store_true", help="Show the patches and exit"
)
parser.add_argument(
"-p",
"--patches",
help="File path to file containing patches in a JSON format",
type=pathlib.Path,
)
parser.add_argument(
"--inplace",
action=argparse.BooleanOptionalAction,
default=False,
help="Whether write the changes",
)

parser.add_argument("-o", "--output", help="Output file", type=pathlib.Path)

return parser

Expand All @@ -265,7 +264,6 @@ def build_argparse() -> argparse.ArgumentParser:
parser = build_argparse()
args = parser.parse_args()

contents = args.orig_file.read_text()
if args.patches:
patches = {
cls_name: {
Expand All @@ -275,7 +273,7 @@ def build_argparse() -> argparse.ArgumentParser:
for cls_name, tests in json.loads(args.patches.read_text()).items()
}
else:
patches = build_patch_dict(iter_patches(contents))
patches = build_patch_dict(iter_patches(args.gather_from.read_text()))

if args.show_patches:
patches = {
Expand All @@ -285,13 +283,15 @@ def build_argparse() -> argparse.ArgumentParser:
}
for cls_name, tests in patches.items()
}
output = json.dumps(patches, indent=4)
sys.stdout.write(f"{output}\n")
output = json.dumps(patches, indent=4) + "\n"
if args.output:
args.output.write_text(output)
else:
sys.stdout.write(f"{output}\n")
sys.exit(0)

patched = apply_patches(args.remote_file.read_text(), patches)

if args.inplace:
args.orig_file.write_text(patched)
patched = apply_patches(args.to.read_text(), patches)
if args.output:
args.output.write_text(patched)
else:
sys.stdout.write(patched)