Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions docs/markers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ Reference
:raises InvalidMarker: If the given ``markers`` are not parseable, then
this exception will be raised.

.. method:: evaluate(environment=None)
.. method:: evaluate(environment=None, context='metadata')

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

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

.. py:data:: packaging.markers.EvaluateContext

A ``typing.Literal`` enumerating valid values for the ``context`` passed to ``Marker.evaluate``, namely:

* "metadata" (for core metadata; default)
* "lock_file" (for lock files)
* "requirement" (i.e. all other situations)

.. function:: default_environment()

Returns a dictionary representing the current Python process. This is the
Expand Down
1 change: 1 addition & 0 deletions src/packaging/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .utils import canonicalize_name

__all__ = [
"Environment",
"EvaluateContext",
"InvalidMarker",
"Marker",
Expand Down
Loading