refactor(bootstrapper): simplify top-level requirement interface#1212
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthrough
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/fromager/bootstrapper.py (1)
329-341: 🧹 Nitpick | 🔵 Trivial | 💤 Low valueConsider adding
versionaddeddirective for the new public API.This is a new public method with a different signature than the former
bootstrap(req, req_type). Per coding guidelines, user-facing changes should include Sphinx version directives for documentation.def bootstrap(self, requirements: list[Requirement]) -> None: """Bootstrap all top-level requirements and their transitive dependencies. + .. versionadded:: X.Y + Replaces the former ``bootstrap(req, req_type)`` signature. + Resolves each requirement, adds it to the dependency graph, and processes🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/fromager/bootstrapper.py` around lines 329 - 341, The bootstrap method in the bootstrapper.py file is a new public API with a modified signature that requires documentation of when it was introduced. Add a Sphinx versionadded directive to the docstring of the bootstrap method, placing it after the main description and before the Args section. The directive should follow the format `.. versionadded:: <version>` to document this as a new or changed public API per the coding guidelines.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_bootstrapper.py`:
- Around line 764-787: The assertion at the end of
test_bootstrap_two_requirements_both_processed converts dispatch_calls to a set
for comparison, which masks duplicate processing of the same requirement. Change
the assertion to compare the sorted list directly instead of converting to a
set, so that duplicate dispatches of pkg1 or pkg2 are caught and the test fails
when a requirement is processed more than once. This ensures the test actually
verifies that each requirement is processed exactly once without duplicates.
---
Nitpick comments:
In `@src/fromager/bootstrapper.py`:
- Around line 329-341: The bootstrap method in the bootstrapper.py file is a new
public API with a modified signature that requires documentation of when it was
introduced. Add a Sphinx versionadded directive to the docstring of the
bootstrap method, placing it after the main description and before the Args
section. The directive should follow the format `.. versionadded:: <version>` to
document this as a new or changed public API per the coding guidelines.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0d0c3b1d-72d2-4dcc-8362-da9b30571f20
📒 Files selected for processing (6)
src/fromager/bootstrapper.pysrc/fromager/commands/bootstrap.pytests/test_bootstrap.pytests/test_bootstrap_test_mode.pytests/test_bootstrapper.pytests/test_bootstrapper_iterative.py
💤 Files with no reviewable changes (1)
- tests/test_bootstrap.py
Add public `bootstrap(requirements: list[Requirement])` that combines the resolution loop (previously `resolve_and_add_top_level()`) and the DFS processing loop into a single method. Callers no longer need to manage `requirement_ctxvar` context or track which requirements resolved successfully. Rename the old `bootstrap(req, req_type)` to `_bootstrap_one()` (private) since it is only used by the git URL resolution path in `_handle_build_requirements()`. Rename `resolve_and_add_top_level()` to `_resolve_and_add_top_level()` (private) as it is now only called inside `bootstrap()`. `bootstrap()` and `_bootstrap_one()` shared an identical DFS while-loop. Extract it into `_run_bootstrap_loop(stack)` so there is a single implementation to maintain. Remove the per-requirement failed-version reporting block from `_bootstrap_one()` since `finalize()` already produces a complete summary. Update `commands/bootstrap.py` to replace the two-loop pattern with a single `bt.bootstrap(to_build)` call, and remove the now-unused `requirement_ctxvar` import. Update all affected tests to use the renamed private methods or the new public interface. Closes: python-wheel-build#1211 Co-Authored-By: Claude <claude@anthropic.com> Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
a13e1fd to
4d82de9
Compare
|
Tick the box to add this pull request to the merge queue (same as
|
Pull Request Description
What
Add public
bootstrap(requirements: list[Requirement])that combines the resolution loop (previouslyresolve_and_add_top_level()) and the DFS processing loop into a single method. Callers no longer need to managerequirement_ctxvarcontext or track which requirements resolved successfully.Rename the old
bootstrap(req, req_type)to_bootstrap_one()(private) since it is only used by the git URL resolution path in_handle_build_requirements(). Renameresolve_and_add_top_level()to_resolve_and_add_top_level()(private) as it is now only called insidebootstrap().bootstrap()and_bootstrap_one()shared an identical DFS while-loop. Extract it into_run_bootstrap_loop(stack)so there is a single implementation to maintain.Remove the per-requirement failed-version reporting block from
_bootstrap_one()sincefinalize()already produces a complete summary.Update
commands/bootstrap.pyto replace the two-loop pattern with a singlebt.bootstrap(to_build)call, and remove the now-unusedrequirement_ctxvarimport.Update all affected tests to use the renamed private methods or the new public interface.
Why
Closes: #1211