Skip to content

Commit 5de9865

Browse files
authored
Document markers.EvaluateContext (#1008)
1 parent 39ce7d4 commit 5de9865

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

docs/markers.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ Reference
5858
:raises InvalidMarker: If the given ``markers`` are not parseable, then
5959
this exception will be raised.
6060

61-
.. method:: evaluate(environment=None)
61+
.. method:: evaluate(environment=None, context='metadata')
6262

6363
Evaluate the marker given the context of the current Python process.
6464

6565
:param dict environment: A dictionary containing keys and values to
6666
override the detected environment.
67-
:param str context: A string representing the context in which the marker is evaluated.
68-
Acceptable values are "metadata" (for core metadata; default),
69-
"lock_file", and "requirement" (i.e. all other situations).
67+
:param EvaluateContext context: A string representing the context in which
68+
the marker is evaluated.
7069
:raises: UndefinedComparison: If the marker uses a comparison on strings
7170
which are not valid versions per the
7271
:ref:`specification of version specifiers
@@ -81,6 +80,14 @@ Reference
8180
A dictionary that represents a Python environment as captured by
8281
:func:`default_environment`.
8382

83+
.. py:data:: packaging.markers.EvaluateContext
84+
85+
A ``typing.Literal`` enumerating valid values for the ``context`` passed to ``Marker.evaluate``, namely:
86+
87+
* "metadata" (for core metadata; default)
88+
* "lock_file" (for lock files)
89+
* "requirement" (i.e. all other situations)
90+
8491
.. function:: default_environment()
8592

8693
Returns a dictionary representing the current Python process. This is the

src/packaging/markers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .utils import canonicalize_name
1818

1919
__all__ = [
20+
"Environment",
2021
"EvaluateContext",
2122
"InvalidMarker",
2223
"Marker",

0 commit comments

Comments
 (0)