File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def _filter_jax_requirements(requirements_content: str) -> str:
8383 return "" .join (filtered_lines )
8484
8585
86- def _parse_pyproject_dependencies (pyproject_path : str ) -> str | None :
86+ def _parse_pyproject_dependencies (pyproject_path : str ) -> str :
8787 """Extract ``[project.dependencies]`` from a pyproject.toml file.
8888
8989 Reads only the core dependency list defined under the ``[project]`` table.
@@ -95,14 +95,15 @@ def _parse_pyproject_dependencies(pyproject_path: str) -> str | None:
9595
9696 Returns:
9797 Newline-separated dependency strings in PEP 508 format suitable for
98- ``pip install``, or ``None`` if the file declares no dependencies.
98+ ``pip install``, or an empty string if the file declares no
99+ dependencies.
99100 """
100101 with open (pyproject_path , "rb" ) as f :
101102 data = tomllib .load (f )
102103
103104 deps = data .get ("project" , {}).get ("dependencies" , [])
104105 if not deps :
105- return None
106+ return ""
106107 return "\n " .join (deps ) + "\n "
107108
108109
Original file line number Diff line number Diff line change @@ -93,17 +93,17 @@ def test_extracts_dependencies(self):
9393 result = _parse_pyproject_dependencies (path )
9494 self .assertEqual (result , "numpy>=1.20\n pandas\n " )
9595
96- def test_returns_none_when_no_dependencies (self ):
96+ def test_returns_empty_when_no_dependencies (self ):
9797 path = self ._write_toml ("[project]\n name = 'foo'\n " )
98- self .assertIsNone (_parse_pyproject_dependencies (path ))
98+ self .assertEqual (_parse_pyproject_dependencies (path ), "" )
9999
100- def test_returns_none_when_no_project_table (self ):
100+ def test_returns_empty_when_no_project_table (self ):
101101 path = self ._write_toml ("[tool.ruff]\n line-length = 88\n " )
102- self .assertIsNone (_parse_pyproject_dependencies (path ))
102+ self .assertEqual (_parse_pyproject_dependencies (path ), "" )
103103
104- def test_returns_none_for_empty_dependencies (self ):
104+ def test_returns_empty_for_empty_dependencies (self ):
105105 path = self ._write_toml ("[project]\n dependencies = []\n " )
106- self .assertIsNone (_parse_pyproject_dependencies (path ))
106+ self .assertEqual (_parse_pyproject_dependencies (path ), "" )
107107
108108 def test_ignores_optional_dependencies (self ):
109109 path = self ._write_toml (
You can’t perform that action at this time.
0 commit comments