Skip to content

Commit

Permalink
Fix no-anchor nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleFromNVIDIA committed May 29, 2024
1 parent c63624a commit 405b042
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rapids_pre_commit_hooks/alpha_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def create_specifier_string(specifiers):
else None
)
if anchor not in used_anchors:
used_anchors.add(anchor)
if anchor is not None:
used_anchors.add(anchor)
has_alpha_spec = any(str(s) == ALPHA_SPECIFIER for s in req.specifier)
if args.mode == "development" and not has_alpha_spec:
linter.add_warning(
Expand Down
21 changes: 21 additions & 0 deletions test/rapids_pre_commit_hooks/test_alpha_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ def test_check_package_spec_anchor():
"""\
- &cudf cudf>=24.04,<24.06
- *cudf
- cuml>=24.04,<24.06
- rmm>=24.04,<24.06
"""
)
args = Mock(mode="development")
Expand All @@ -160,12 +162,31 @@ def test_check_package_spec_anchor():
)
assert linter.warnings == expected_linter.warnings
assert used_anchors == {"cudf"}

alpha_spec.check_package_spec(
linter, args, loader.document_anchors[0], used_anchors, composed.value[1]
)
assert linter.warnings == expected_linter.warnings
assert used_anchors == {"cudf"}

expected_linter.add_warning(
(37, 55), "add alpha spec for RAPIDS package cuml"
).add_replacement((37, 55), "cuml>=24.04,<24.06,>=0.0.0a0")
alpha_spec.check_package_spec(
linter, args, loader.document_anchors[0], used_anchors, composed.value[2]
)
assert linter.warnings == expected_linter.warnings
assert used_anchors == {"cudf"}

expected_linter.add_warning(
(58, 75), "add alpha spec for RAPIDS package rmm"
).add_replacement((58, 75), "rmm>=24.04,<24.06,>=0.0.0a0")
alpha_spec.check_package_spec(
linter, args, loader.document_anchors[0], used_anchors, composed.value[3]
)
assert linter.warnings == expected_linter.warnings
assert used_anchors == {"cudf"}


@pytest.mark.parametrize(
["content", "indices"],
Expand Down

0 comments on commit 405b042

Please sign in to comment.