docs: add docstrings and comments to complex functions#1047
docs: add docstrings and comments to complex functions#1047LalatenduMohanty wants to merge 2 commits intopython-wheel-build:mainfrom
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 (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis PR adds docstrings and inline comments across many src/fromager modules (finders, resolver, bootstrapper, wheels, sources, dependencies, pyproject, external_commands, requirements_file, dependency_graph, vendor_rust). It also makes three behavioral changes: bootstrapper now re-extracts a wheel’s build tag and rejects non-matching wheels, dependency filtering passes the parent requirement’s extras into marker evaluation, and requirements_file evaluates markers using a separate marker environment per extra value. No public signatures were changed. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 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 |
14113ea to
38f90a7
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/fromager/bootstrapper.py (1)
1081-1089:⚠️ Potential issue | 🟠 MajorHandle invalid cached wheel filenames as cache misses.
At Line 1084, a parse failure from
extract_info_from_wheel_file()can abort bootstrap during cache lookup. This path should degrade to “not cached” and continue.Proposed fix
- _, _, build_tag, _ = wheels.extract_info_from_wheel_file(req, wheel_filename) + try: + _, _, build_tag, _ = wheels.extract_info_from_wheel_file( + req, wheel_filename + ) + except ValueError as err: + logger.info( + "ignoring cached artifact with invalid wheel filename %s: %s", + wheel_filename, + err, + ) + return None, None🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/fromager/bootstrapper.py` around lines 1081 - 1089, The call to wheels.extract_info_from_wheel_file(req, wheel_filename) may raise a parse error and currently can abort bootstrap; wrap that call in a try/except that catches the parse/validation exception (e.g., ValueError or the specific exception raised by extract_info_from_wheel_file) and treat it as a cache miss by logging a debug/info message and returning (None, None) so execution continues; update the logic around extract_info_from_wheel_file and the subsequent expected_build_tag check to rely on the safe, exception-handled result.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/fromager/bootstrapper.py`:
- Around line 1081-1089: The call to wheels.extract_info_from_wheel_file(req,
wheel_filename) may raise a parse error and currently can abort bootstrap; wrap
that call in a try/except that catches the parse/validation exception (e.g.,
ValueError or the specific exception raised by extract_info_from_wheel_file) and
treat it as a cache miss by logging a debug/info message and returning (None,
None) so execution continues; update the logic around
extract_info_from_wheel_file and the subsequent expected_build_tag check to rely
on the safe, exception-handled result.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cc6ee430-a315-4dbc-8dac-78e8d6cb8470
📒 Files selected for processing (11)
src/fromager/bootstrapper.pysrc/fromager/dependencies.pysrc/fromager/dependency_graph.pysrc/fromager/external_commands.pysrc/fromager/finders.pysrc/fromager/pyproject.pysrc/fromager/requirements_file.pysrc/fromager/resolver.pysrc/fromager/sources.pysrc/fromager/vendor_rust.pysrc/fromager/wheels.py
2b46652 to
cee17ce
Compare
Add docstrings to functions and inline comments to non-obvious code patterns across various files. Only targets genuinely complex logic that would be hard for new contributors to understand. Closes: python-wheel-build#1046 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
cee17ce to
3c2ad0f
Compare
jskladan
left a comment
There was a problem hiding this comment.
Obviously, all of these are nitpicks, but since we're talking docs, they feel appropriate.
I see nothing wrong with the MR as-is, so hitting that Approve button (FWIW), and leaving it up to you.
| visited: set[str], | ||
| ) -> typing.Iterable[DependencyEdge]: | ||
| # Depth-first walk of install requirement edges, skipping nodes | ||
| # already visited to avoid loops in the dependency graph. |
There was a problem hiding this comment.
Not that it does any harm, but the comment describes pretty self-explanatory code, while not adding any important context/information in the same fashion the other comments do. There is no (non-obvious) "why" explained.
| graph = cls() | ||
| # Stack-based DFS to reconstruct graph from serialized dict, | ||
| # skipping nodes already visited to avoid processing shared | ||
| # dependencies twice. |
There was a problem hiding this comment.
This feels like it could have been a docstring instead, if you want to keep it in? Othervise, also feels that it does not add much value other than describing "what" code does (and we have the code to describe what it does already :)).
| raise NotImplementedError("GenericProvider does not implement caching") | ||
|
|
||
| def find_candidates(self, identifier: typing.Any) -> Candidates: | ||
| # Accepts three input formats from _version_source: |
There was a problem hiding this comment.
How about we make this a docstring instead?
rd4398
left a comment
There was a problem hiding this comment.
This looks good to me. I will wait for Lala to address comments on PR
Add docstrings to functions and inline comments to non-obvious code patterns across various files. Only targets genuinely complex logic that would be hard for new contributors to understand.
Though my goal was to help contributors but it has also a positive impact on AI code assistants. When an AI assistant needs to understand a function, it either reads the docstring or reads the entire function body. A good docstring lets it understand the function's purpose and behavior without consuming context window on implementation details.
Closes: #1046