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
from poetry.console.commands.command import Command
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:
......@@ -437,14 +437,10 @@ You can specify a package in the following forms:
except (PyProjectException, RuntimeError):
cwd = Path.cwd()
return [
parse_dependency_specification(
requirement=requirement,
env=self.env if isinstance(self, EnvCommand) else None,
cwd=cwd,
)
for requirement in requirements
]
parser = RequirementsParser(
self.env if isinstance(self, EnvCommand) else None, cwd
)
return [parser.parse(requirement) for requirement in requirements]
def _format_requirements(self, requirements: list[dict[str, str]]) -> Requirements:
requires: Requirements = {}
......
......@@ -7,7 +7,7 @@ import pytest
from deepdiff import DeepDiff
from poetry.utils.dependency_specification import parse_dependency_specification
from poetry.utils.dependency_specification import RequirementsParser
if TYPE_CHECKING:
......@@ -116,5 +116,5 @@ def test_parse_dependency_specification(
mocker.patch("pathlib.Path.exists", _mock)
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