Skip to content

Commit

Permalink
fix asserts causing flake8 linter failures (#1369)
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
  • Loading branch information
maxnbk authored Aug 28, 2022
1 parent 5457615 commit c52772e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/rez/release_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, pkg_root, vcs_root=None):
"path %s" % (self.name(), pkg_root))
vcs_root = result[0]
else:
assert(self.is_valid_root(vcs_root))
assert self.is_valid_root(vcs_root)

self.vcs_root = vcs_root
self.pkg_root = pkg_root
Expand Down
4 changes: 2 additions & 2 deletions src/rez/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ def _create_ex():
shell_command = d["command"]
else:
if d["stdin"]:
assert(self.stdin_arg)
assert self.stdin_arg
shell_command = "%s %s" % (self.executable, self.stdin_arg)
quiet = True
elif do_rcfile:
assert(self.rcfile_arg)
assert self.rcfile_arg
shell_command = "%s %s" % (self.executable, self.rcfile_arg)
else:
shell_command = self.executable
Expand Down
10 changes: 5 additions & 5 deletions src/rez/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ def extract(self):
if not package_request:
return (self, None)

assert(new_slice is not self.variant_slice)
assert new_slice is not self.variant_slice
scope = copy.copy(self)
scope.variant_slice = new_slice
if self.pr:
Expand Down Expand Up @@ -1477,7 +1477,7 @@ def finalise(self):
correctly ordered; or, if cyclic dependencies were detected, a new
phase marked as cyclic.
"""
assert(self._is_solved())
assert self._is_solved()
g = self._get_minimal_graph()
scopes = dict((x.package_name, x) for x in self.scopes
if not x.is_conflict)
Expand Down Expand Up @@ -1532,7 +1532,7 @@ def split(self):
A 2-tuple of _ResolvePhase objects, where the first phase is the
best contender for resolving.
"""
assert(self.status == SolverStatus.exhausted)
assert self.status == SolverStatus.exhausted

scopes = []
next_scopes = []
Expand Down Expand Up @@ -2202,7 +2202,7 @@ def solve_step(self):

else:
self.pr.subheader("EXHAUSTED:")
assert(new_phase.status == SolverStatus.exhausted)
assert new_phase.status == SolverStatus.exhausted
self._push_phase(new_phase)

def failure_reason(self, failure_index=None):
Expand Down Expand Up @@ -2331,7 +2331,7 @@ def _latest_nonfailed_phase(self):
for phase in reversed(self.phase_stack):
if phase.status not in (SolverStatus.failed, SolverStatus.cyclic):
return phase
assert(False) # should never get here
assert False # should never get here

def _do_callback(self):
keep_going = True
Expand Down
4 changes: 2 additions & 2 deletions src/rez/utils/py_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ def _dst(p):
else:
# this is an egg-file
import zipfile
assert(is_egg and os.path.isfile(dist.location))
assert(zipfile.is_zipfile(dist.location))
assert is_egg and os.path.isfile(dist.location)
assert zipfile.is_zipfile(dist.location)
z = zipfile.ZipFile(dist.location)
z.extractall(root_path)

Expand Down
6 changes: 3 additions & 3 deletions src/rez/utils/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _noattrib():
# to something. This stops code like "print(instance.notexist)" from
# adding empty attributes
attr_ = self._create_child_attribute(attr)
assert(isinstance(attr_, RecursiveAttribute))
assert isinstance(attr_, RecursiveAttribute)
attr_.__dict__["pending"] = (attr, self)
return attr_

Expand Down Expand Up @@ -219,8 +219,8 @@ def __call__(self, name):

def _scope_exit(self, name):
scope = self.scope_stack.pop()
assert(self.scope_stack)
assert(name == scope.name)
assert self.scope_stack
assert name == scope.name
data = {scope.name: scope.to_dict()}
self.scope_stack[-1].update(data)

Expand Down
2 changes: 1 addition & 1 deletion src/rezplugins/release_vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_relative_to_remote(self):
try:
s2 = toks[-1]
adj, n = s2.split()
assert(adj in ("ahead", "behind"))
assert adj in ("ahead", "behind")
n = int(n)
return -n if adj == "behind" else n
except Exception as e:
Expand Down

0 comments on commit c52772e

Please sign in to comment.