Skip to content

Commit 290ad20

Browse files
committed
Use reST docstring formatting where appropriate
1 parent ec43859 commit 290ad20

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

piptools/resolver.py

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ class BaseResolver(metaclass=ABCMeta):
152152

153153
@abstractmethod
154154
def resolve(self, max_rounds: int) -> set[InstallRequirement]:
155-
"""
155+
r"""
156156
Find concrete package versions for all the given InstallRequirements
157-
and their recursive dependencies and return a set of pinned
158-
``InstallRequirement``'s.
157+
and their recursive dependencies.
158+
:returns: a set of pinned ``InstallRequirement``\ s.
159159
"""
160160

161161
def resolve_hashes(
@@ -199,9 +199,24 @@ def __init__(
199199
allow_unsafe: bool = False,
200200
unsafe_packages: set[str] | None = None,
201201
) -> None:
202-
"""
203-
Make sure the legacy resolver is enabled and no backtracking resolver
204-
is present.
202+
"""Initialize LegacyResolver.
203+
204+
:param constraints: the constraints given
205+
:type constraints: Iterable[InstallRequirement]
206+
:param existing_constraints: constraints already present
207+
:param repository: the repository to get the constraints from
208+
:type repository: BaseRepository
209+
:param cache: the cache to be used
210+
:param prereleases: whether prereleases should be taken into account when resolving
211+
(default is :py:data:`False`)
212+
:param clear_caches: whether to clear repository and dependency caches before resolving
213+
(default is :py:data:`False`)
214+
:param allow_unsafe: whether unsafe packages should be allowed in the resulting requirements
215+
(default is :py:data:`False`)
216+
:param unsafe_packages: packages to be considered as unsafe
217+
(default is :py:data:`None`)
218+
:type unsafe_packages: set[str]
219+
:raises: ``PipToolsError`` if the legacy resolver is not enabled
205220
"""
206221
self.our_constraints = set(constraints)
207222
self.their_constraints: set[InstallRequirement] = set()
@@ -230,13 +245,14 @@ def constraints(self) -> set[InstallRequirement]:
230245

231246
def resolve(self, max_rounds: int = 10) -> set[InstallRequirement]:
232247
r"""
233-
Find concrete package versions for all the given InstallRequirements
248+
Find concrete package versions for all the given ``InstallRequirement``\ s
234249
and their recursive dependencies and return a set of pinned
235250
``InstallRequirement``\ s.
236251
237252
Resolves constraints one round at a time, until they don't change
238-
anymore. Protects against infinite loops by breaking out after a max
239-
number rounds.
253+
anymore.
254+
:param max_rounds: break out of resolution process after the given number of rounds
255+
to prevent infinite loops (default is 10)
240256
"""
241257
if self.clear_caches:
242258
self.dependency_cache.clear()
@@ -324,7 +340,7 @@ def _resolve_one_round(self) -> tuple[bool, set[InstallRequirement]]:
324340
package versions. Some of these constraints may be new
325341
or updated.
326342
327-
Returns whether new constraints appeared in this round. If no
343+
:returns: whether new constraints appeared in this round. If no
328344
constraints were added or changed, this indicates a stable
329345
configuration.
330346
"""
@@ -536,8 +552,8 @@ def resolve(self, max_rounds: int = 10) -> set[InstallRequirement]:
536552
Resolve given ireqs.
537553
538554
Find concrete package versions for all the given InstallRequirements
539-
and their recursive dependencies and return a set of pinned
540-
``InstallRequirement``\ s.
555+
and their recursive dependencies.
556+
:returns: a set of pinned ``InstallRequirement``\ s.
541557
"""
542558
with update_env_context_manager(
543559
PIP_EXISTS_ACTION="i"
@@ -644,7 +660,7 @@ def _do_resolve(
644660
"""
645661
Resolve dependencies based on resolvelib ``Resolver``.
646662
647-
Return :py:data:`True` on successful resolution, otherwise remove problematic
663+
:returns: :py:data:`True` on successful resolution, otherwise remove problematic
648664
requirements from existing constraints and return false.
649665
"""
650666
try:

piptools/sync.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@
4343
def dependency_tree(
4444
installed_keys: Mapping[str, Distribution], root_key: str
4545
) -> set[str]:
46-
"""Calculate the dependency tree for a package
46+
"""Calculate the dependency tree for a package.
4747
4848
Return a collection of all of the package's dependencies.
4949
Uses a DFS traversal algorithm.
5050
5151
``installed_keys`` should be a {key: requirement} mapping, e.g.
5252
{'django': from_line('django==1.8')}
53-
``root_key`` should be the key to return the dependency tree for.
53+
:param root_key: the key to return the dependency tree for
54+
:type root_key: str
5455
"""
5556
dependencies = set()
5657
queue: Deque[Distribution] = collections.deque()
@@ -127,7 +128,7 @@ def diff_key_from_ireq(ireq: InstallRequirement) -> str:
127128
128129
For URL requirements, only provide a useful key if the url includes
129130
a hash, e.g. #sha1=..., in any of the supported hash algorithms.
130-
Otherwise return ireq.link so the key will not match and the package will
131+
Otherwise return ``ireq.link`` so the key will not match and the package will
131132
reinstall. Reinstall is necessary to ensure that packages will reinstall
132133
if the contents at the URL have changed but the version has not.
133134
"""

piptools/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ def override_defaults_from_config_file(
531531
file, returning the ``pathlib.Path`` of that config file if specified or
532532
discovered.
533533
534-
Return :py:data:`None` if no such file is found.
534+
:returns: :py:data:`None` if no such file is found.
535535
536536
``pip-tools`` will use the first config file found, searching in this order:
537537
an explicitly given config file, a ``.pip-tools.toml``, a ``pyproject.toml``

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ skip_install = true
5252

5353
[testenv:pip-compile-docs]
5454
description = compile requirements for the documentation
55+
changedir = {[testenv:build-docs]changedir}
5556
commands_pre =
56-
commands = python -m piptools compile --strip-extras --allow-unsafe --quiet docs/requirements.in {posargs}
57+
commands = python -m piptools compile --strip-extras --allow-unsafe --quiet requirements.in {posargs}
5758

5859
[testenv:build-docs]
5960
description = build the documentation

0 commit comments

Comments
 (0)