File tree Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,20 @@ def get_version_from_dependency(tool: str) -> Optional[str]:
2626 for dep in requires :
2727 if dep .startswith (f"{ tool } ==" ):
2828 return dep .split ("==" )[1 ]
29+
30+ # Check project.dependencies
31+ dependencies = data .get ("project" , {}).get ("dependencies" , [])
32+ for dep in dependencies :
33+ if dep .startswith (f"{ tool } ==" ):
34+ return dep .split ("==" )[1 ]
35+
36+ # Check project.optional-dependencies (all groups)
37+ optional_deps = data .get ("project" , {}).get ("optional-dependencies" , {})
38+ for group in optional_deps .values ():
39+ for dep in group :
40+ if dep .startswith (f"{ tool } ==" ):
41+ return dep .split ("==" )[1 ]
42+
2943 return None
3044
3145
Original file line number Diff line number Diff line change 2525def test_get_version_from_dependency_success ():
2626 """Test get_version_from_dependency with valid pyproject.toml."""
2727 mock_toml_content = {
28- "project" : {
29- "build-system" : {
30- "requires" : [
31- "clang-format==20.1.7" ,
32- "clang-tidy==20.1.0" ,
33- "other-package==1.0.0" ,
34- ]
35- }
36- }
28+ "build-system" : {
29+ "requires" : [
30+ "clang-format==20.1.7" ,
31+ "clang-tidy==20.1.0" ,
32+ "other-package==1.0.0" ,
33+ ]
34+ },
35+ "project" : {},
3736 }
3837
3938 with (
@@ -176,7 +175,7 @@ def test_resolve_install_tool_already_installed_correct_version():
176175 patch ("shutil.which" , return_value = mock_path ),
177176 ):
178177 result = _resolve_install ("clang-format" , "20.1.7" )
179- assert result == Path (mock_path )
178+ assert Path ( result ) == Path (mock_path )
180179
181180
182181@pytest .mark .benchmark
You can’t perform that action at this time.
0 commit comments