summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2018-02-14 15:58:42 +0000
committerJames Ennis <james.ennis@codethink.com>2018-03-14 14:10:26 +0000
commit4741d1379a6e17048423f0e08588b607668ab98a (patch)
tree91d1815aa482df35786cebb94d4a650a073194d4
parent05fa346f9911638b272eca0b62a110b590803ab2 (diff)
downloadbuildstream-4741d1379a6e17048423f0e08588b607668ab98a.tar.gz
pylint - dealt with len-as-condition warning
-rw-r--r--.pylintrc1
-rw-r--r--buildstream/_artifactcache/artifactcache.py2
-rw-r--r--buildstream/_artifactcache/ostreecache.py2
-rw-r--r--buildstream/_artifactcache/pushreceive.py6
-rw-r--r--buildstream/_frontend/main.py2
-rw-r--r--buildstream/_frontend/widget.py6
-rw-r--r--buildstream/_pipeline.py10
-rw-r--r--buildstream/_scheduler/queue.py4
-rw-r--r--buildstream/_scheduler/trackqueue.py2
-rw-r--r--buildstream/_variables.py2
10 files changed, 18 insertions, 19 deletions
diff --git a/.pylintrc b/.pylintrc
index fe59cc304..bea08ac7f 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -112,7 +112,6 @@ disable=#####################################
# Messages that report warnings which should be addressed #
###########################################################
- len-as-condition,
logging-format-interpolation,
no-member,
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 4d1e18aa5..5f3f337d1 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -40,7 +40,7 @@ class ArtifactCacheSpec(namedtuple('ArtifactCacheSpec', 'url push')):
_yaml.node_validate(spec_node, ['url', 'push'])
url = _yaml.node_get(spec_node, str, 'url')
push = _yaml.node_get(spec_node, bool, 'push', default_value=False)
- if len(url) == 0:
+ if not url:
provenance = _yaml.node_get_provenance(spec_node)
raise LoadError(LoadErrorReason.INVALID_DATA,
"{}: empty artifact cache URL".format(provenance))
diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py
index 30f0105f0..7d14ac079 100644
--- a/buildstream/_artifactcache/ostreecache.py
+++ b/buildstream/_artifactcache/ostreecache.py
@@ -334,7 +334,7 @@ class OSTreeCache(ArtifactCache):
push_remotes = [r for r in self._remotes[project] if r.spec.push]
- if len(push_remotes) == 0:
+ if not push_remotes:
raise ArtifactError("Push is not enabled for any of the configured remote artifact caches.")
refs = [buildref(element, key) for key in keys]
diff --git a/buildstream/_artifactcache/pushreceive.py b/buildstream/_artifactcache/pushreceive.py
index b23dc1a84..33f19859c 100644
--- a/buildstream/_artifactcache/pushreceive.py
+++ b/buildstream/_artifactcache/pushreceive.py
@@ -247,7 +247,7 @@ class PushMessageReader(object):
def read(self):
header = self.file.read(HEADER_SIZE)
- if len(header) == 0:
+ if not header:
# Remote end quit
return None, None
order, version, cmdtype, size = self.decode_header(header)
@@ -510,7 +510,7 @@ class OSTreePusher(object):
remote_rev = remote_refs.get(branch, '0' * 64)
if rev != remote_rev:
update_refs[branch] = remote_rev, rev
- if len(update_refs) == 0:
+ if not update_refs:
logging.info('Nothing to update')
self.writer.send_done()
return self.close()
@@ -632,7 +632,7 @@ class OSTreeReceiver(object):
self.reader.receive_done()
# If we didn't get any objects, we're done
- if len(received_objects) == 0:
+ if not received_objects:
return 0
# Got all objects, move them to the object store
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index e6f365de2..1b6c46239 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -481,7 +481,7 @@ def prefix_choice_value_proc(choices):
def value_proc(user_input):
remaining_candidate = [choice for choice in choices if choice.startswith(user_input)]
- if len(remaining_candidate) == 0:
+ if not remaining_candidate:
raise UsageError("Expected one of {}, got {}".format(choices, user_input))
elif len(remaining_candidate) == 1:
return remaining_candidate[0]
diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py
index b427d00fd..c68f1df39 100644
--- a/buildstream/_frontend/widget.py
+++ b/buildstream/_frontend/widget.py
@@ -348,7 +348,7 @@ class LogLine(Widget):
def _parse_logfile_format(self, format_string, content_profile, format_profile):
logfile_tokens = []
- while len(format_string) > 0:
+ while format_string:
if format_string.startswith("%%"):
logfile_tokens.append(FixedText("%", content_profile, format_profile))
format_string = format_string[2:]
@@ -523,7 +523,7 @@ class LogLine(Widget):
text += '\n'
# Project Options
- if len(project._options.variables) > 0:
+ if project._options.variables:
text += self.content_profile.fmt("Project Options\n", bold=True)
values = OrderedDict()
for key in sorted(project._options.variables):
@@ -703,7 +703,7 @@ class LogLine(Widget):
if "%{workspace-dirs" in format:
dirs = [path.replace(os.getenv('HOME', '/root'), '~')
for path in element._workspace_dirs()]
- if len(dirs) > 0:
+ if dirs:
line = p.fmt_subst(
line, 'workspace-dirs', "Workspaces: " + ", ".join(dirs))
else:
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index f30f25667..489fdc769 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -153,7 +153,7 @@ class Pipeline():
if use_configured_remote_caches:
for project in self.context._get_projects():
artifact_caches = configured_remote_artifact_cache_specs(self.context, project)
- if len(artifact_caches) > 0:
+ if artifact_caches: # artifact_caches is a list of ArtifactCacheSpec instances
self.artifacts.set_remotes(artifact_caches, project=project)
has_remote_caches = True
if has_remote_caches:
@@ -413,7 +413,7 @@ class Pipeline():
# elements
#
def build(self, scheduler, build_all, track_first, save):
- if len(self.unused_workspaces) > 0:
+ if self.unused_workspaces:
self.message(MessageType.WARN, "Unused workspaces",
detail="\n".join([el for el, _
in self.unused_workspaces]))
@@ -560,9 +560,9 @@ class Pipeline():
target = self.targets[0]
workdir = os.path.abspath(directory)
- if len(list(target.sources())) == 0:
+ if not list(target.sources()):
build_depends = [x.name for x in target.dependencies(Scope.BUILD, recurse=False)]
- if len(build_depends) == 0:
+ if not build_depends:
raise PipelineError("The given element has no sources or build-dependencies")
detail = "Try opening a workspace on one of its dependencies instead:\n"
detail += " \n".join(build_depends)
@@ -586,7 +586,7 @@ class Pipeline():
fetch = FetchQueue(skip_cached=True)
queues.append(fetch)
- if len(queues) > 0:
+ if queues:
queues[0].enqueue(plan)
elapsed, status = scheduler.run(queues)
diff --git a/buildstream/_scheduler/queue.py b/buildstream/_scheduler/queue.py
index 1b4990100..10b3bfeca 100644
--- a/buildstream/_scheduler/queue.py
+++ b/buildstream/_scheduler/queue.py
@@ -167,14 +167,14 @@ class Queue():
self.skipped_elements.extend(skip)
def dequeue(self):
- while len(self.done_queue) > 0:
+ while self.done_queue:
yield self.done_queue.popleft()
def process_ready(self):
scheduler = self.scheduler
unready = []
- while len(self.wait_queue) > 0 and scheduler.get_job_token(self.queue_type):
+ while self.wait_queue and scheduler.get_job_token(self.queue_type):
element = self.wait_queue.popleft()
status = self.status(element)
diff --git a/buildstream/_scheduler/trackqueue.py b/buildstream/_scheduler/trackqueue.py
index f78479c49..50ae804ac 100644
--- a/buildstream/_scheduler/trackqueue.py
+++ b/buildstream/_scheduler/trackqueue.py
@@ -47,7 +47,7 @@ class TrackQueue(Queue):
def status(self, element):
# We can skip elements entirely if they have no sources.
- if len(list(element.sources())) == 0:
+ if not list(element.sources()):
return QueueStatus.SKIP
return QueueStatus.READY
diff --git a/buildstream/_variables.py b/buildstream/_variables.py
index f36458dc0..9d4e72c47 100644
--- a/buildstream/_variables.py
+++ b/buildstream/_variables.py
@@ -145,7 +145,7 @@ class Variables():
resolved = variables
unmatched = ['dummy']
last_unmatched = ['dummy']
- while len(unmatched) > 0:
+ while unmatched:
resolved, unmatched = resolve_one(resolved)
# Lists of strings can be compared like this