Unifying branches - #38
Conversation
Reviewer's GuideCentralizes recursive subgraph naming contracts and naming tree node construction, standardizes shortcut tree schemas, and refines how optionally parenthesized stereochemical substituent names are carried through and rendered in component and substituent formatting. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Hey - I've left some high level feedback:
- In
build_shortcut_tree_node, thedecisionsargument is passed through tobuild_naming_tree_nodeasnested_decisions; renaming the parameter tonested_decisions(and updating call sites) would make its purpose clearer and keep terminology consistent across the helpers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `build_shortcut_tree_node`, the `decisions` argument is passed through to `build_naming_tree_node` as `nested_decisions`; renaming the parameter to `nested_decisions` (and updating call sites) would make its purpose clearer and keep terminology consistent across the helpers.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new RecursiveSubgraphNamer protocol makes upstream_atom a positional-or-keyword argument instead of keyword-only, which may be stricter than some existing implementations (that declare upstream_atom as keyword-only) and can cause static type-checking friction; consider keeping upstream_atom keyword-only in the protocol (adding a * before it) to better match existing callables.
- RenderedSubstituentName is a str subclass with an attached outer_parentheses_optional attribute, but slicing and many string operations will drop the subclass (and thus the flag); it may be worth adding a short comment near its definition or usage to clarify that this loss is intentional and only boundary-aware names are expected to carry the marker.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new RecursiveSubgraphNamer protocol makes upstream_atom a positional-or-keyword argument instead of keyword-only, which may be stricter than some existing implementations (that declare upstream_atom as keyword-only) and can cause static type-checking friction; consider keeping upstream_atom keyword-only in the protocol (adding a * before it) to better match existing callables.
- RenderedSubstituentName is a str subclass with an attached outer_parentheses_optional attribute, but slicing and many string operations will drop the subclass (and thus the flag); it may be worth adding a short comment near its definition or usage to clarify that this loss is intentional and only boundary-aware names are expected to carry the marker.
## Individual Comments
### Comment 1
<location path="src/openclatura/naming_protocols.py" line_range="14-17" />
<code_context>
- @overload
- def __call__(
- self,
- mol: Molecule,
- start_idx: int,
- exclude_atoms: set[int],
- *,
- upstream_atom: int | None = None,
- return_trace: Literal[False] = False,
- return_tree: Literal[False] = False,
</code_context>
<issue_to_address>
**issue:** Align `RecursiveSubgraphNamer` parameter kinds (keyword-only vs positional) with existing implementations.
The protocol currently allows `upstream_atom` as positional‑or‑keyword (`upstream_atom: int | None = None, *`), while existing namer implementations take it as keyword‑only (`*, upstream_atom: int | None = None`). This mismatch means implementations that enforce keyword‑only don’t strictly conform to the protocol and can trigger type‑checker errors. Please update the protocol overloads to make `upstream_atom` keyword‑only (after `*`), matching the existing `BranchNamer`/`SubgraphNamer` signatures and call sites.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| mol: Molecule, | ||
| start_idx: int, | ||
| exclude_atoms: set[int], | ||
| upstream_atom: int | None = None, |
There was a problem hiding this comment.
issue: Align RecursiveSubgraphNamer parameter kinds (keyword-only vs positional) with existing implementations.
The protocol currently allows upstream_atom as positional‑or‑keyword (upstream_atom: int | None = None, *), while existing namer implementations take it as keyword‑only (*, upstream_atom: int | None = None). This mismatch means implementations that enforce keyword‑only don’t strictly conform to the protocol and can trigger type‑checker errors. Please update the protocol overloads to make upstream_atom keyword‑only (after *), matching the existing BranchNamer/SubgraphNamer signatures and call sites.
Summary by Sourcery
Unify recursive subgraph naming and tree construction, and refine how stereochemical substituent boundaries are represented and formatted.
New Features:
Enhancements:
Tests: