Commit 3248fe17 by Randy Döring

refactor: group functions for requirements parsing into a class (#7693)

parent 65486660
...@@ -13,7 +13,7 @@ from tomlkit import inline_table ...@@ -13,7 +13,7 @@ from tomlkit import inline_table
from poetry.console.commands.command import Command from poetry.console.commands.command import Command
from poetry.console.commands.env_command import EnvCommand from poetry.console.commands.env_command import EnvCommand
from poetry.utils.dependency_specification import parse_dependency_specification from poetry.utils.dependency_specification import RequirementsParser
if TYPE_CHECKING: if TYPE_CHECKING:
...@@ -437,14 +437,10 @@ You can specify a package in the following forms: ...@@ -437,14 +437,10 @@ You can specify a package in the following forms:
except (PyProjectException, RuntimeError): except (PyProjectException, RuntimeError):
cwd = Path.cwd() cwd = Path.cwd()
return [ parser = RequirementsParser(
parse_dependency_specification( self.env if isinstance(self, EnvCommand) else None, cwd
requirement=requirement, )
env=self.env if isinstance(self, EnvCommand) else None, return [parser.parse(requirement) for requirement in requirements]
cwd=cwd,
)
for requirement in requirements
]
def _format_requirements(self, requirements: list[dict[str, str]]) -> Requirements: def _format_requirements(self, requirements: list[dict[str, str]]) -> Requirements:
requires: Requirements = {} requires: Requirements = {}
......
...@@ -7,7 +7,7 @@ import pytest ...@@ -7,7 +7,7 @@ import pytest
from deepdiff import DeepDiff from deepdiff import DeepDiff
from poetry.utils.dependency_specification import parse_dependency_specification from poetry.utils.dependency_specification import RequirementsParser
if TYPE_CHECKING: if TYPE_CHECKING:
...@@ -116,5 +116,5 @@ def test_parse_dependency_specification( ...@@ -116,5 +116,5 @@ def test_parse_dependency_specification(
mocker.patch("pathlib.Path.exists", _mock) mocker.patch("pathlib.Path.exists", _mock)
assert not DeepDiff( assert not DeepDiff(
parse_dependency_specification(requirement), specification, ignore_order=True RequirementsParser().parse(requirement), specification, ignore_order=True
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment