-
Notifications
You must be signed in to change notification settings - Fork 3
fix: move clang tools dependencies to optional #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
47140e7
789b90b
7e6bf7a
fb84f57
3bbd310
7d82a56
e748d10
b8eb49e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,11 +102,13 @@ def test_get_version_from_dependency_success(): | |
"""Test get_version_from_dependency with valid pyproject.toml.""" | ||
mock_toml_content = { | ||
"project": { | ||
"dependencies": [ | ||
"clang-format==20.1.7", | ||
"clang-tidy==20.1.0", | ||
"other-package==1.0.0", | ||
] | ||
"optional-dependencies": { | ||
"tools": [ | ||
"clang-format==20.1.7", | ||
"clang-tidy==20.1.0", | ||
"other-package==1.0.0", | ||
] | ||
} | ||
} | ||
} | ||
|
||
|
@@ -132,7 +134,9 @@ def test_get_version_from_dependency_missing_file(): | |
@pytest.mark.benchmark | ||
def test_get_version_from_dependency_missing_dependency(): | ||
"""Test get_version_from_dependency with missing dependency.""" | ||
mock_toml_content = {"project": {"dependencies": ["other-package==1.0.0"]}} | ||
mock_toml_content = { | ||
"project": {"optional-dependencies": {"tools": ["other-package==1.0.0"]}} | ||
} | ||
|
||
with ( | ||
patch("pathlib.Path.exists", return_value=True), | ||
|
@@ -155,6 +159,30 @@ def test_get_version_from_dependency_malformed_toml(): | |
assert result is None | ||
|
||
|
||
@pytest.mark.benchmark | ||
def test_get_version_from_dependency_fallback_to_dependencies(): | ||
"""Test get_version_from_dependency falls back to project.dependencies.""" | ||
mock_toml_content = { | ||
"project": { | ||
"dependencies": [ | ||
"clang-format==20.1.7", | ||
"clang-tidy==20.1.0", | ||
"other-package==1.0.0", | ||
] | ||
} | ||
} | ||
|
||
with ( | ||
patch("pathlib.Path.exists", return_value=True), | ||
patch("cpp_linter_hooks.util.tomllib.load", return_value=mock_toml_content), | ||
): | ||
result = get_version_from_dependency("clang-format") | ||
assert result == "20.1.7" | ||
|
||
result = get_version_from_dependency("clang-tidy") | ||
assert result == "20.1.0" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainTest expects fallback behavior that's missing in implementation. This test validates fallback to the old This test confirms that fallback functionality should exist but is missing from the implementation. Run this test to verify it fails: 🏁 Script executed: #!/bin/bash
# Description: Run the specific fallback test to verify it fails due to missing implementation
python -m pytest tests/test_util.py::test_get_version_from_dependency_fallback_to_dependencies -v Length of output: 9788 🏁 Script executed: #!/bin/bash
rg -n "def get_version_from_dependency" -A 20 -B 5 cpp_linter_hooks/util.py Length of output: 1002 Implement fallback to Locations to update: Suggested patch: # First try project.optional-dependencies.tools
optional_deps = data.get("project", {}).get("optional-dependencies", {})
tools_deps = optional_deps.get("tools", [])
for dep in tools_deps:
if dep.startswith(f"{tool}=="):
return dep.split("==")[1]
+ # Fallback to project.dependencies
+ project_deps = data.get("project", {}).get("dependencies", [])
+ for dep in project_deps:
+ if dep.startswith(f"{tool}=="):
+ return dep.split("==")[1]
+
return None
🤖 Prompt for AI Agents
|
||
|
||
# Tests for _resolve_version | ||
@pytest.mark.benchmark | ||
@pytest.mark.parametrize( | ||
|
Uh oh!
There was an error while loading. Please reload this page.