◐ Shell
clean mode source ↗

update_lib hard dependency resolver by youknowone · Pull Request #6817 · RustPython/RustPython

📝 Walkthrough

Walkthrough

This PR extends the library update toolchain with a new dependency resolution module (deps.py), improves error handling with TestRunError exception, refactors multi-file copying support via a helper function, and adjusts path resolution for __init__.py files. Comprehensive tests are added across all modified modules.

Changes

Cohort / File(s) Summary
Documentation & Configuration
\.claude/commands/upgrade-pylib\.md
Minor indentation adjustment in the STOP section for formatting alignment.
Error Handling & Test Validation
scripts/update_lib/auto_mark\.py
Introduces TestRunError exception class. Replaces capture_output with stdout=PIPE and stderr=None for selective output handling. Adds validation in _is_super_call_only to match method names. Raises TestRunError when test runs produce no results.
Multi-File Copy Support
scripts/update_lib/copy_lib\.py
Introduces private helper _copy_single() for single file/directory copies. Refactors copy_lib() to detect /Lib/ paths and copy multiple files via get_lib_paths(), with fallback to single-file mode.
Dependency Resolution (New Module)
scripts/update_lib/deps\.py
New module implementing dependency resolution with functions: get_lib_paths(), get_test_paths(), get_data_paths(), parse_test_imports(), get_test_dependencies(), and resolve_all_paths(). Includes DEPENDENCIES and TEST_DEPENDENCIES mappings for irregular library layouts and test-specific path overrides.
Import Insertion
scripts/update_lib/patch_spec\.py
Replaces unconditional assertion with guarded fallback logic: returns last import line if present, otherwise returns docstring end line, else returns 0.
Path Resolution
scripts/update_lib/path\.py
Adjusts lib_to_test_path() to use parent directory name when encountering __init__.py instead of the literal filename.
Workflow Enhancement
scripts/update_lib/quick\.py
Adds Step 1.5 to process test dependencies after initial patch via get_test_dependencies(). Introduces DEPENDENCIES-based overrides in _expand_shortcut(). Adds exception handling for TestRunError with clean error output.
Test Suite (New & Updated)
scripts/update_lib/tests/test_auto_mark\.py, test_copy_lib\.py, test_deps\.py, test_patch_spec\.py, test_path\.py, test_quick\.py
Comprehensive unit tests added: validation of _is_super_call_only, _copy_single file/directory operations, dependency resolution across all path types, import insertion fallback logic, __init__.py parent name handling, shortcut overrides, and test failure scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Remake update_lib #6796: Continuation of the same update\_lib toolchain development, modifying identical modules (auto\_mark.py, copy\_lib.py, patch\_spec.py, path.py, quick.py) and introducing the new deps.py and test infrastructure.

Poem

🐰 With paths untangled and tests that stand firm,
Dependencies mapped—our toolchain does turn!
From __init__.py secrets to copies that scale,
This rabbit hops faster, leaves no library pale.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'update_lib hard dependency resolver' accurately captures the main objective of this PR, which is to implement dependency resolution so that updating datetime triggers _pydatetime updates.
Docstring Coverage ✅ Passed Docstring coverage is 96.49% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.