Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #393 from dephell/docstrings
Browse files Browse the repository at this point in the history
A bit more docstrings
  • Loading branch information
orsinium committed Mar 16, 2020
2 parents fa0d6fc + ae488de commit f6ab55b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Binary file added assets/logo-min.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions dephell/controllers/_mutator.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,23 @@ def _make_snapshot(groups: Iterable[Group]) -> Tuple[str, ...]:

def _check_soft(self, groups: Sequence[Group], deps: Sequence[Dependency],
conflict: Dependency) -> bool:
"""True if that mutation wasn't tried before
"""
return self._make_snapshot(groups) not in self._snapshots

def _check_not_empty(self, groups: Sequence[Group], deps: Sequence[Dependency],
conflict: Dependency) -> bool:
"""True if chosen groups have no conflicts
"""
for group in groups:
if group.empty:
return False
return self._check_soft(groups=groups, deps=deps, conflict=conflict)

def _check_in_subgraph(self, groups: Sequence[Group], deps: Sequence[Dependency],
conflict: Dependency) -> bool:
"""True if the mutation changes state of mutation parents
"""
if not self._check_not_empty(groups=groups, deps=deps, conflict=conflict):
return False
# any new group has to change state of the subgraph
Expand Down Expand Up @@ -122,6 +128,8 @@ def _check_in_subgraph(self, groups: Sequence[Group], deps: Sequence[Dependency]

def _check_in_conflict(self, groups: Sequence[Group], deps: Sequence[Dependency],
conflict: Dependency) -> bool:
"""True if any direct parent of conflict was mutated
"""
if not self._check_not_empty(groups=groups, deps=deps, conflict=conflict):
return False
state = {dep.name: dict(dep.constraint.specs) for dep in deps if not isinstance(dep, RootDependency)}
Expand All @@ -138,4 +146,6 @@ def _check_in_conflict(self, groups: Sequence[Group], deps: Sequence[Dependency]
return False

def remember(self, groups: Iterable[Group]) -> None:
"""Remember given mutation to not repeat it in the future.
"""
self._snapshots.add(self._make_snapshot(groups))

0 comments on commit f6ab55b

Please sign in to comment.