Skip to content

Commit 7efc33e

Browse files
dimblebyradoering
authored andcommitted
remove marker.constraint_string
1 parent 2beb1b6 commit 7efc33e

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

src/poetry/core/version/markers.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ def __init__(
192192
self._constraint: BaseConstraint | VersionConstraint
193193
self._parser: Callable[[str], BaseConstraint | VersionConstraint]
194194
self._name = ALIASES.get(name, name)
195-
self._constraint_string = str(constraint)
195+
constraint_string = str(constraint)
196196

197197
# Extract operator and value
198-
m = self._CONSTRAINT_RE.match(self._constraint_string)
198+
m = self._CONSTRAINT_RE.match(constraint_string)
199199
if m is None:
200-
raise ValueError(f"Invalid marker '{self._constraint_string}'")
200+
raise ValueError(f"Invalid marker '{constraint_string}'")
201201

202202
self._operator = m.group(1)
203203
if self._operator is None:
@@ -227,11 +227,10 @@ def __init__(
227227

228228
self._constraint = self._parser(glue.join(versions))
229229
else:
230-
self._constraint = self._parser(self._constraint_string)
230+
self._constraint = self._parser(constraint_string)
231231
else:
232232
# if we have a in/not in operator we split the constraint
233233
# into a union/multi-constraint of single constraint
234-
constraint_string = self._constraint_string
235234
if self._operator in {"in", "not in"}:
236235
op, glue = ("==", " || ") if self._operator == "in" else ("!=", ", ")
237236
values = re.split("[ ,]+", self._value)
@@ -243,13 +242,6 @@ def __init__(
243242
def name(self) -> str:
244243
return self._name
245244

246-
@property
247-
def constraint_string(self) -> str:
248-
if self._operator in {"in", "not in"}:
249-
return f"{self._operator} {self._value}"
250-
251-
return self._constraint_string
252-
253245
@property
254246
def constraint(self) -> BaseConstraint | VersionConstraint:
255247
return self._constraint

tests/version/test_markers.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,24 @@ def test_single_marker() -> None:
2424

2525
assert isinstance(m, SingleMarker)
2626
assert m.name == "sys_platform"
27-
assert m.constraint_string == "==darwin"
27+
assert str(m.constraint) == "darwin"
2828

2929
m = parse_marker('python_version in "2.7, 3.0, 3.1"')
3030

3131
assert isinstance(m, SingleMarker)
3232
assert m.name == "python_version"
33-
assert m.constraint_string == "in 2.7, 3.0, 3.1"
3433
assert str(m.constraint) == ">=2.7.0,<2.8.0 || >=3.0.0,<3.2.0"
3534

3635
m = parse_marker('"2.7" in python_version')
3736

3837
assert isinstance(m, SingleMarker)
3938
assert m.name == "python_version"
40-
assert m.constraint_string == "in 2.7"
4139
assert str(m.constraint) == ">=2.7.0,<2.8.0"
4240

4341
m = parse_marker('python_version not in "2.7, 3.0, 3.1"')
4442

4543
assert isinstance(m, SingleMarker)
4644
assert m.name == "python_version"
47-
assert m.constraint_string == "not in 2.7, 3.0, 3.1"
4845
assert str(m.constraint) == "<2.7.0 || >=2.8.0,<3.0.0 || >=3.2.0"
4946

5047
m = parse_marker(
@@ -54,10 +51,6 @@ def test_single_marker() -> None:
5451

5552
assert isinstance(m, SingleMarker)
5653
assert m.name == "platform_machine"
57-
assert (
58-
m.constraint_string
59-
== "in x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32"
60-
)
6154
assert (
6255
str(m.constraint)
6356
== "x86_64 || X86_64 || aarch64 || AARCH64 || ppc64le || PPC64LE || amd64 ||"
@@ -71,11 +64,6 @@ def test_single_marker() -> None:
7164

7265
assert isinstance(m, SingleMarker)
7366
assert m.name == "platform_machine"
74-
assert (
75-
m.constraint_string
76-
== "not in x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32"
77-
" WIN32"
78-
)
7967
assert (
8068
str(m.constraint)
8169
== "!=x86_64, !=X86_64, !=aarch64, !=AARCH64, !=ppc64le, !=PPC64LE, !=amd64,"

0 commit comments

Comments
 (0)