Skip to content

Commit 9f25bef

Browse files
authored
Update comparison rules for version and string markers
Clarify comparison rules for version and string markers in dependency specifiers.
1 parent 7158046 commit 9f25bef

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

source/specifications/dependency-specifiers.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,24 @@ vulnerability. Markers were first standardised in :pep:`345`. This document
197197
fixes some issues that were observed in the design described in :pep:`426`.
198198

199199
Comparisons in marker expressions are based on the types in the table below.
200-
The types marked with ``Version`` or ``Version | String`` use the version
200+
The variables marked with ``Version`` or ``Version | String`` use the version
201201
comparison rules of the :ref:`Version specifier specification
202202
<version-specifiers>` when those are defined (that is when both sides have a
203203
valid version specifier). If both sides are not expressible as a ``Version``,
204204
then ``==``, ``>=``, and ``<=`` check for exact equality; no ordering is
205-
assumed. On the other values, operators perform the same as they do for strings
205+
assumed. On other operators, operators perform the same as they do for strings
206206
or sets in Python based on whether the marker value is a string or set itself.
207207
Otherwise an error should be raised. e.g. the following will result in errors::
208208

209209
"dog" ~= "fred"
210210
python_version ~= "surprise"
211211

212-
Values that are marked as ``String`` may also follow same rules as ``Version``
213-
defined above, with ``>=`` and ``<=`` being equivalent to ``==``, and ``<`` and
214-
``>`` always evaluating to ``False``. This is legacy behavior due to an older
215-
version of this spec, and tools may choose to warn or fail if these are used on
216-
strings.
212+
Variables that are marked solely as ``String`` support `==` and `!=`; ordered
213+
comparison operators may also follow same rules as ``Version`` defined above
214+
when not a valid Version, with ``>=`` and ``<=`` being equivalent to ``==``,
215+
and ``<`` and ``>`` always evaluating to ``False``. This is legacy behavior
216+
due to an older version of this spec, and tools may choose to warn or fail
217+
if orderd comparisons are used on ``String`` markers.
217218

218219
User supplied constants are always encoded as strings with either ``'`` or
219220
``"`` quote marks. Note that backslash escapes are not defined, but existing

0 commit comments

Comments
 (0)