8000 lib_updater --quick-upgrade by youknowone · Pull Request #6695 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

lib_updater --quick-upgrade#6695

Merged
youknowone merged 1 commit intoRustPython:mainfrom
youknowone:lib-updater
Jan 10, 2026
Merged

lib_updater --quick-upgrade#6695
youknowone merged 1 commit intoRustPython:mainfrom
youknowone:lib-updater

Conversation

@youknowone
Copy link
Member
@youknowone youknowone commented Jan 10, 2026

make it easier for most common scenario.

cc @terryluan12

Summary by CodeRabbit

  • New Features

    • Introduced a new command-line option that accepts a library path and automatically detects and configures necessary upgrade parameters, simplifying the upgrade workflow.
  • Refactor

    • Modified argument validation logic to support the new quick upgrade functionality while maintaining compatibility with existing command-line workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor
coderabbitai bot commented Jan 10, 2026
📝 Walkthrough

Walkthrough

This PR introduces a --quick-upgrade CLI option to the lib_updater script that enables streamlined library updates. When provided with a path containing /Lib/, it auto-populates the gather_from, to, and output arguments, reducing manual configuration overhead while reusing existing validation logic.

Changes

Cohort / File(s) Summary
CLI Enhancement
scripts/lib_updater.py
Added --quick-upgrade argument accepting a path to enable simplified upgrade workflows; modified mutual exclusion group from required=True to required=False to accommodate new auto-fill logic; implemented path validation and argument auto-population based on /Lib/ path structure

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • RustPython#6089: Extends scripts/lib_updater.py with the same --quick-upgrade CLI option and implements mutually-exclusive argument group adjustments with runtime auto-fill logic for upgrade workflows.

Suggested reviewers

  • reactive-firewall

Poem

🐰 A shortcut now hops into view,
Quick-upgrade makes patching true,
With paths validated with care,
And auto-fill beyond compare,
Library bouncing, faster brew! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a new --quick-upgrade option to the lib_updater tool to simplify the most common upgrade scenario.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ff7b3e and a32d4a7.

📒 Files selected for processing (1)
  • scripts/lib_updater.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.py: In most cases, Python code should not be edited; bug fixes should be made through Rust code modifications only
Follow PEP 8 style for custom Python code
Use ruff for linting Python code

Files:

  • scripts/lib_updater.py
🧠 Learnings (3)
📚 Learning: 2025-08-30T14:40:05.858Z
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 6089
File: scripts/lib_updater.py:292-297
Timestamp: 2025-08-30T14:40:05.858Z
Learning: In scripts/lib_updater.py, the --inplace flag intentionally writes to orig_file (not remote_file) even though patches are applied to remote_file content. This workflow allows updating the original RustPython test file with patches applied to new upstream CPython content.

Applied to files:

  • scripts/lib_updater.py
📚 Learning: 2025-09-07T05:38:31.690Z
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 6089
File: scripts/lib_updater.py:198-202
Timestamp: 2025-09-07T05:38:31.690Z
Learning: In scripts/lib_updater.py, the iter_patches function intentionally does not handle SyntaxError from ast.parse(contents). The author confirmed this behavior is fine and intended - the tool should fail fast on unparseable files rather than silently skip processing.

Applied to files:

  • scripts/lib_updater.py
📚 Learning: 2025-12-27T14:03:49.034Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-27T14:03:49.034Z
Learning: Applies to Lib/** : Minimize modifications to CPython standard library files in the `Lib/` directory; the only allowed operation is copying files from CPython

Applied to files:

  • scripts/lib_updater.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Run rust tests (windows-2025)
  • GitHub Check: Run snippets and cpython tests (windows-2025)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Ensure compilation on various targets
🔇 Additional comments (5)
scripts/lib_updater.py (5)

5-14: Documentation clearly explains the new feature.

The Quick Upgrade section provides helpful examples and explains the auto-detection behavior effectively.


301-306: New argument definition looks good.

The --quick-upgrade argument is properly configured within the mutually exclusive group and uses appropriate types.


320-320: Correctly relaxes validation for quick-upgrade workflow.

Changing to required=False is appropriate since validation is now handled manually at lines 357-362 to accommodate the auto-fill behavior of --quick-upgrade.


357-362: Validation logic is correct and comprehensive.

The manual validation properly handles all argument combinations and provides clear error messages that mention the --quick-upgrade option for user convenience.


341-356: Fix cross-platform path separator handling.

The code searches for the literal string /Lib/ in the path. On Windows, pathlib.Path objects use backslashes when converted to strings, so a path like cpython\Lib\test\foo.py won't match /Lib/, causing the validation to fail with a confusing error message.

🔧 Proposed fix for cross-platform compatibility
     # Quick upgrade: auto-fill --from, --to, -o from path
     if args.quick_upgrade is not None:
-        path_str = str(args.quick_upgrade)
+        path_str = args.quick_upgrade.as_posix()
         lib_marker = "/Lib/"

The as_posix() method always returns paths with forward slashes, ensuring consistent behavior across platforms.


Consider checking for explicit --to argument.

Lines 352-353 unconditionally set args.to even if the user explicitly provided --to with --quick-upgrade. This could be confusing since argparse allows both arguments but the explicit --to is silently ignored.

Consider either:

  1. Checking if args.to was already set and skip overriding it, or
  2. Adding --to to the mutually exclusive group with --quick-upgrade

Likely an incorrect or invalid review comment.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youknowone youknowone marked this pull request as ready for review January 10, 2026 15:04
Copy link
Contributor
@ShaharNaveh ShaharNaveh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

@youknowone youknowone merged commit 3909b18 into RustPython:main Jan 10, 2026
13 checks passed
@youknowone youknowone deleted the lib-updater branch January 10, 2026 15:11
terryluan12 pushed a commit to terryluan12/RustPython that referenced this pull request Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0