Skip to content

Refactor anchor handling when reading dependencies.yaml - #148

Merged
rapids-bot[bot] merged 4 commits into
rapidsai:mainfrom
KyleFromNVIDIA:refactor-yaml-anchor
Aug 5, 2026
Merged

Refactor anchor handling when reading dependencies.yaml#148
rapids-bot[bot] merged 4 commits into
rapidsai:mainfrom
KyleFromNVIDIA:refactor-yaml-anchor

Conversation

@KyleFromNVIDIA

@KyleFromNVIDIA KyleFromNVIDIA commented Aug 4, 2026

Copy link
Copy Markdown
Member

Preserve more information about anchors and let the handler decide whether or not to descend into an anchor reference. In the future, this will allow us to update the cuda_suffixed and use_cuda_wheels checks to descent into anchor references. For now, keep them as they are.

Also check for the new constraints output type from DFG 1.22.0.

Preserve more information about anchors and let the handler decide
whether or not to descend into an anchor reference. In the future,
this will allow us to update the `cuda_suffixed` and
`use_cuda_wheels` checks to descent into anchor references. For now,
keep them as they are.
@KyleFromNVIDIA
KyleFromNVIDIA requested a review from a team as a code owner August 4, 2026 19:30
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Improved YAML anchor handling when validating dependency packages.
    • Preserved anchor names in automatic package corrections.
    • Added support for requirements dependency outputs.
    • Avoided duplicate warnings for packages inherited through YAML references.
  • Bug Fixes

    • Corrected package traversal and validation for shared anchors and anchored package lists.
    • Expanded coverage for dependency parsing and anchor-related scenarios.

Walkthrough

The change introduces typed YAML anchor definitions and references. Package traversal now propagates anchor metadata to handlers. Alpha specification and CUDA dependency handlers skip reference-anchored packages, preserve anchor names, and add coverage for definitions, references, and anchored package collections.

Changes

Anchor-aware package validation

Layer / File(s) Summary
Anchor model and classification
src/rapids_pre_commit_hooks/utils/yaml.py, tests/rapids_pre_commit_hooks/utils/test_yaml.py
Adds AnchorType, Anchor, and reference-anchor detection. Updates anchor tests for the new return model.
Anchor propagation through YAML traversal
src/rapids_pre_commit_hooks/utils/dependencies_yaml.py, tests/rapids_pre_commit_hooks/utils/test_dependencies_yaml.py
Passes typed anchors through package and package-list traversal. Tests cover missing, defined, referenced, and reused anchors.
Alpha specification anchor handling
src/rapids_pre_commit_hooks/alpha_spec.py, tests/rapids_pre_commit_hooks/test_alpha_spec.py
Tracks anchored package contexts, skips reference anchors, and emits anchor names in replacements.
Dependency handler anchor handling
src/rapids_pre_commit_hooks/dependencies/cuda_suffixed.py, src/rapids_pre_commit_hooks/dependencies/use_cuda_wheels.py, tests/rapids_pre_commit_hooks/dependencies/*
Adds typed package contexts, skips reference-anchored packages, recognizes requirements, and records anchor names in findings.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: bdice

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: refactoring anchor handling in dependencies.yaml.
Description check ✅ Passed The description accurately covers the anchor-handling refactor and support for the constraints output type.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@src/rapids_pre_commit_hooks/alpha_spec.py`:
- Around line 58-68: Update AlphaSpecHandler.__init__ to declare a None return
type, and replace the Any annotation on handle_packages parameter
common_or_matrices_item_context with object to satisfy Ruff while accepting all
values.

In `@tests/rapids_pre_commit_hooks/utils/test_yaml.py`:
- Around line 85-86: Replace the parameter-name list literals with tuples in all
affected pytest.mark.parametrize decorators:
tests/rapids_pre_commit_hooks/utils/test_yaml.py lines 85-86;
tests/rapids_pre_commit_hooks/utils/test_dependencies_yaml.py lines 181-182 and
240-241; tests/rapids_pre_commit_hooks/test_alpha_spec.py lines 137-138 and
168-176; and tests/rapids_pre_commit_hooks/dependencies/test_use_cuda_wheels.py
lines 435-436 and 527-534. Preserve each decorator’s existing parameter names
and test data unchanged.
🪄 Autofix

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: ASSERTIVE

Plan: Enterprise

Run ID: e31796d2-ed69-4c52-beb5-a173c743bd4b

📥 Commits

Reviewing files that changed from the base of the PR and between dce67fe and 7ebf639.

📒 Files selected for processing (10)
  • src/rapids_pre_commit_hooks/alpha_spec.py
  • src/rapids_pre_commit_hooks/dependencies/cuda_suffixed.py
  • src/rapids_pre_commit_hooks/dependencies/use_cuda_wheels.py
  • src/rapids_pre_commit_hooks/utils/dependencies_yaml.py
  • src/rapids_pre_commit_hooks/utils/yaml.py
  • tests/rapids_pre_commit_hooks/dependencies/test_cuda_suffixed.py
  • tests/rapids_pre_commit_hooks/dependencies/test_use_cuda_wheels.py
  • tests/rapids_pre_commit_hooks/test_alpha_spec.py
  • tests/rapids_pre_commit_hooks/utils/test_dependencies_yaml.py
  • tests/rapids_pre_commit_hooks/utils/test_yaml.py

Comment thread src/rapids_pre_commit_hooks/alpha_spec.py
Comment thread tests/rapids_pre_commit_hooks/utils/test_yaml.py
@KyleFromNVIDIA

Copy link
Copy Markdown
Member Author

@coderabbitai We don't typically use docstrings in this repository. We generally only use them for complex functions that may not be self-evident to the reader.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@KyleFromNVIDIA Understood. I will not recommend docstrings by default. I will recommend them only for complex functions where the behavior is not self-evident.


✏️ Learnings added
Learnt from: KyleFromNVIDIA
URL: https://github.com/rapidsai/pre-commit-hooks/pull/148

Timestamp: 2026-08-05T21:50:37.943Z
Learning: In this repository, do not recommend docstrings by default. Use docstrings only for complex functions whose behavior is not self-evident to the reader.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@KyleFromNVIDIA

Copy link
Copy Markdown
Member Author

/merge

@rapids-bot
rapids-bot Bot merged commit d8d915a into rapidsai:main Aug 5, 2026
4 checks passed
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