@@ -131,3 +131,55 @@ def resolve(self, requirements, **kwargs):
131131 :raises: ``self.base_exception`` or its subclass.
132132 """
133133 raise NotImplementedError
134+
135+ def narrow_requirement_selection (
136+ self , identifiers , resolutions , candidates , information , backtrack_causes
137+ ):
138+ """
139+ Narrows the selection of requirements being considered during
140+ resolution.
141+
142+ The requirement selection is defined as "The possible requirements
143+ that will be resolved next." If a requirement isn't part of the returned
144+ iterable, it will not be considered during the next step of resolution.
145+
146+ :param identifiers: An iterable of `identifier` as returned by
147+ ``identify()``. These identify all requirements currently being
148+ considered.
149+ :param resolutions: Mapping of candidates currently pinned by the
150+ resolver. Each key is an identifier, and the value is a candidate.
151+ The candidate may conflict with requirements from ``information``.
152+ :param candidates: Mapping of each dependency's possible candidates.
153+ Each value is an iterator of candidates.
154+ :param information: Mapping of requirement information of each package.
155+ Each value is an iterator of *requirement information*.
156+ :param backtrack_causes: Sequence of *requirement information* that are
157+ the requirements that caused the resolver to most recently
158+ backtrack.
159+
160+ A *requirement information* instance is a named tuple with two members:
161+
162+ * ``requirement`` specifies a requirement contributing to the current
163+ list of candidates.
164+ * ``parent`` specifies the candidate that provides (depended on) the
165+ requirement, or ``None`` to indicate a root requirement.
166+
167+ Must return a non-empty subset of `identifiers`, with the simplest
168+ implementation being to return `identifiers` unchanged.
169+
170+ Can be used by the provider to optimize the dependency resolution
171+ process. `get_preference` will only be called on the identifiers
172+ returned. If there is only one identifier returned, then `get_preference`
173+ won't be called at all.
174+
175+ Serving a similar purpose as `get_preference`, this method allows the
176+ provider to guide resolvelib through the resolution process. It should
177+ be used instead of `get_preference` when the provider needs to consider
178+ multiple identifiers simultaneously, or when the provider wants to skip
179+ checking all identifiers, e.g., because the checks are prohibitively
180+ expensive.
181+
182+ Returns:
183+ Iterable[KT]: A non-empty subset of `identifiers`.
184+ """
185+ return identifiers
0 commit comments