Skip to content

Commit

Permalink
Simplify docstrings and indents
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Apr 28, 2020
1 parent 4aa7160 commit c770818
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/pypi_wheel_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_extras_for(self, dependency):
return tuple(sorted(dependency.extras))

def get_base_requirement(self, candidate):
return Requirement("{} == {}".format(candidate.name, candidate.version))
return Requirement("{}=={}".format(candidate.name, candidate.version))

def get_preference(self, resolution, candidates, information):
return len(candidates)
Expand Down
3 changes: 2 additions & 1 deletion examples/reporter_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def find_matches(self, requirement):
return deps

def is_satisfied_by(self, requirement, candidate):
return candidate[0] == requirement[0] and candidate[1] in requirement[1]
assert candidate[0] == requirement[0]
return candidate[1] in requirement[1]

def get_dependencies(self, candidate):
return self.candidates[candidate]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
requires = ['setuptools>=36.2.2', 'wheel>=0.28.0']

[tool.black]
line-length = 80
line-length = 79
include = '^/(docs|examples|src|tasks|tests)/.+\.py$'

[tool.towncrier]
Expand Down
36 changes: 11 additions & 25 deletions src/resolvelib/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def find_matches(self, requirement):
def is_satisfied_by(self, requirement, candidate):
"""Whether the given requirement can be satisfied by a candidate.
The candidate is guarenteed to have been generated from the
requirement.
A boolean should be returned to indicate whether `candidate` is a
viable solution to the requirement.
"""
Expand Down Expand Up @@ -92,30 +95,13 @@ def __init__(self, provider, reporter):
def resolve(self, requirements, **kwargs):
"""Take a collection of constraints, spit out the resolution result.
Parameters
----------
requirements : Collection
A collection of constraints
kwargs : optional
Additional keyword arguments that subclasses may accept.
Raises
------
self.base_exception
Any raised exception is guaranteed to be a subclass of
self.base_exception. The string representation of an exception
should be human readable and provide context for why it occurred.
Returns
-------
retval : object
A representation of the final resolution state. It can be any object
with a `mapping` attribute that is a Mapping. Other attributes can
be used to provide resolver-specific information.
The `mapping` attribute MUST be key-value pair is an identifier of a
requirement (as returned by the provider's `identify` method) mapped
to the resolved candidate (chosen from the return value of the
provider's `find_matches` method).
This returns a representation of the final resolution state, with one
guarenteed attribute ``mapping`` that contains resolved candidates as
values. The keys are their respective identifiers.
:param requirements: A collection of constraints.
:param kwargs: Additional keyword arguments that subclasses may accept.
:raises: ``self.base_exception`` or its subclass.
"""
raise NotImplementedError

0 comments on commit c770818

Please sign in to comment.