summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2018-02-19 10:25:32 +0000
committerJames Ennis <james.ennis@codethink.com>2018-03-14 17:31:06 +0000
commitdfa45f0415bcaa623ee121789a0935100fd34f6a (patch)
tree26a18d9a69999555a489ee7c1cbd54da30d42e59
parent4cfa0bdffbaacfbaf12ec8c6ab2f52bace0ef716 (diff)
downloadbuildstream-dfa45f0415bcaa623ee121789a0935100fd34f6a.tar.gz
pylint - dealt with redefined-outer-name and redefined-built in warnings
-rw-r--r--.pylintrc4
-rw-r--r--buildstream/_artifactcache/pushreceive.py16
-rw-r--r--buildstream/_context.py6
-rw-r--r--buildstream/_frontend/cli.py68
-rw-r--r--buildstream/_frontend/widget.py16
-rw-r--r--buildstream/_ostree.py18
-rw-r--r--buildstream/_profile.py4
-rw-r--r--buildstream/_signals.py8
-rw-r--r--buildstream/_yaml.py4
-rw-r--r--buildstream/utils.py2
10 files changed, 71 insertions, 75 deletions
diff --git a/.pylintrc b/.pylintrc
index 21d5e2e98..1270504e3 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -116,10 +116,6 @@ disable=#####################################
cyclic-import,
- # These are hard to spot without linting, but easy to fix
- redefined-builtin,
- redefined-outer-name,
-
simplifiable-if-statement,
bad-whitespace
diff --git a/buildstream/_artifactcache/pushreceive.py b/buildstream/_artifactcache/pushreceive.py
index db893eb08..48fdef0cf 100644
--- a/buildstream/_artifactcache/pushreceive.py
+++ b/buildstream/_artifactcache/pushreceive.py
@@ -61,24 +61,24 @@ class PushCommandType(Enum):
done = 4
-def msg_byteorder(sys_byteorder=sys.byteorder):
- if sys_byteorder == 'little':
+def msg_byteorder(byteorder=sys.byteorder):
+ if byteorder == 'little':
return 'l'
- elif sys_byteorder == 'big':
+ elif byteorder == 'big':
return 'B'
else:
raise PushException('Unrecognized system byteorder {}'
- .format(sys_byteorder))
+ .format(byteorder))
-def sys_byteorder(msg_byteorder):
- if msg_byteorder == 'l':
+def sys_byteorder(byteorder):
+ if byteorder == 'l':
return 'little'
- elif msg_byteorder == 'B':
+ elif byteorder == 'B':
return 'big'
else:
raise PushException('Unrecognized message byteorder {}'
- .format(msg_byteorder))
+ .format(byteorder))
def ostree_object_path(repo, obj):
diff --git a/buildstream/_context.py b/buildstream/_context.py
index 2db13cf98..e98b0761d 100644
--- a/buildstream/_context.py
+++ b/buildstream/_context.py
@@ -153,14 +153,14 @@ class Context():
'scheduler', 'artifacts', 'logging', 'projects',
])
- for dir in ['sourcedir', 'builddir', 'artifactdir', 'logdir']:
+ for directory in ['sourcedir', 'builddir', 'artifactdir', 'logdir']:
# Allow the ~ tilde expansion and any environment variables in
# path specification in the config files.
#
- path = _yaml.node_get(defaults, str, dir)
+ path = _yaml.node_get(defaults, str, directory)
path = os.path.expanduser(path)
path = os.path.expandvars(path)
- setattr(self, dir, path)
+ setattr(self, directory, path)
# Load artifact share configuration
self.artifact_cache_specs = artifact_cache_specs_from_config_node(defaults)
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index cb15eb205..1f8ebbbb9 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -168,9 +168,9 @@ def cli(context, **kwargs):
# Build Command #
##################################################################
@cli.command(short_help="Build elements in a pipeline")
-@click.option('--all', default=False, is_flag=True,
+@click.option('--all', 'all_', default=False, is_flag=True,
help="Build elements that would not be needed for the current build plan")
-@click.option('--track', multiple=True,
+@click.option('--track', 'track_', multiple=True,
type=click.Path(dir_okay=False, readable=True),
help="Specify elements to track during the build. Can be used "
"repeatedly to specify multiple elements")
@@ -184,26 +184,26 @@ def cli(context, **kwargs):
@click.argument('elements', nargs=-1,
type=click.Path(dir_okay=False, readable=True))
@click.pass_obj
-def build(app, elements, all, track, track_save, track_all, track_except):
+def build(app, elements, all_, track_, track_save, track_all, track_except):
"""Build elements in a pipeline"""
- if track_except and not (track or track_all):
+ if track_except and not (track_ or track_all):
click.echo("ERROR: --track-except cannot be used without --track or --track-all")
sys.exit(-1)
- if track_save and not (track or track_all):
+ if track_save and not (track_ or track_all):
click.echo("ERROR: --track-save cannot be used without --track or --track-all")
sys.exit(-1)
if track_all:
- track = elements
+ track_ = elements
app.initialize(elements, except_=track_except, rewritable=track_save,
- use_configured_remote_caches=True, track_elements=track,
+ use_configured_remote_caches=True, track_elements=track_,
fetch_subprojects=True)
app.print_heading()
try:
- app.pipeline.build(app.scheduler, all, track, track_save)
+ app.pipeline.build(app.scheduler, all_, track_, track_save)
app.print_summary()
except PipelineError as e:
app.print_error(e)
@@ -221,12 +221,12 @@ def build(app, elements, all, track, track_save, track_all, track_except):
@click.option('--deps', '-d', default='plan',
type=click.Choice(['none', 'plan', 'all']),
help='The dependencies to fetch (default: plan)')
-@click.option('--track', default=False, is_flag=True,
+@click.option('--track', 'track_', default=False, is_flag=True,
help="Track new source references before fetching")
@click.argument('elements', nargs=-1,
type=click.Path(dir_okay=False, readable=True))
@click.pass_obj
-def fetch(app, elements, deps, track, except_):
+def fetch(app, elements, deps, track_, except_):
"""Fetch sources required to build the pipeline
By default this will only try to fetch sources which are
@@ -242,13 +242,13 @@ def fetch(app, elements, deps, track, except_):
all: All dependencies
"""
- app.initialize(elements, except_=except_, rewritable=track,
- track_elements=elements if track else None,
+ app.initialize(elements, except_=except_, rewritable=track_,
+ track_elements=elements if track_ else None,
fetch_subprojects=True)
try:
dependencies = app.pipeline.deps_elements(deps)
app.print_heading(deps=dependencies)
- app.pipeline.fetch(app.scheduler, dependencies, track)
+ app.pipeline.fetch(app.scheduler, dependencies, track_)
app.print_summary()
except PipelineError as e:
app.print_error(e)
@@ -381,7 +381,7 @@ def push(app, elements, deps, remote):
@click.option('--order', default="stage",
type=click.Choice(['stage', 'alpha']),
help='Staging or alphabetic ordering of dependencies')
-@click.option('--format', '-f', metavar='FORMAT', default=None,
+@click.option('--format', '-f', 'format_', metavar='FORMAT', default=None,
type=click.STRING,
help='Format string for each element')
@click.option('--downloadable', default=False, is_flag=True,
@@ -389,7 +389,7 @@ def push(app, elements, deps, remote):
@click.argument('elements', nargs=-1,
type=click.Path(dir_okay=False, readable=True))
@click.pass_obj
-def show(app, elements, deps, except_, order, format, downloadable):
+def show(app, elements, deps, except_, order, format_, downloadable):
"""Show elements in the pipeline
By default this will show all of the dependencies of the
@@ -446,10 +446,10 @@ def show(app, elements, deps, except_, order, format, downloadable):
if order == "alpha":
dependencies = sorted(dependencies)
- if not format:
- format = app.context.log_element_format
+ if not format_:
+ format_ = app.context.log_element_format
- report = app.logger.show_pipeline(dependencies, format)
+ report = app.logger.show_pipeline(dependencies, format_)
click.echo(report, color=app.colors)
@@ -457,7 +457,7 @@ def show(app, elements, deps, except_, order, format, downloadable):
# Shell Command #
##################################################################
@cli.command(short_help="Shell into an element's sandbox environment")
-@click.option('--build', '-b', is_flag=True, default=False,
+@click.option('--build', '-b', 'build_', is_flag=True, default=False,
help='Stage dependencies and sources to build')
@click.option('--sysroot', '-s', default=None,
type=click.Path(exists=True, file_okay=False, readable=True),
@@ -471,7 +471,7 @@ def show(app, elements, deps, except_, order, format, downloadable):
type=click.Path(dir_okay=False, readable=True))
@click.argument('command', type=click.STRING, nargs=-1)
@click.pass_obj
-def shell(app, element, sysroot, mount, isolate, build, command):
+def shell(app, element, sysroot, mount, isolate, build_, command):
"""Run a command in the target element's sandbox environment
This will stage a temporary sysroot for running the target
@@ -490,7 +490,7 @@ def shell(app, element, sysroot, mount, isolate, build, command):
"""
from ..element import Scope
from .._project import HostMount
- if build:
+ if build_:
scope = Scope.BUILD
else:
scope = Scope.RUN
@@ -564,7 +564,7 @@ def checkout(app, element, directory, force, integrate, hardlinks):
@click.option('--compression', default='gz',
type=click.Choice(['none', 'gz', 'bz2', 'xz']),
help="Compress the tar file using the given algorithm.")
-@click.option('--track', default=False, is_flag=True,
+@click.option('--track', 'track_', default=False, is_flag=True,
help="Track new source references before building")
@click.option('--force', '-f', default=False, is_flag=True,
help="Overwrite files existing in checkout directory")
@@ -574,13 +574,13 @@ def checkout(app, element, directory, force, integrate, hardlinks):
type=click.Path(dir_okay=False, readable=True))
@click.pass_obj
def source_bundle(app, target, force, directory,
- track, compression, except_):
+ track_, compression, except_):
"""Produce a source bundle to be manually executed"""
- app.initialize((target,), rewritable=track, track_elements=[target] if track else None)
+ app.initialize((target,), rewritable=track_, track_elements=[target] if track_ else None)
try:
dependencies = app.pipeline.deps_elements('all')
app.print_heading(dependencies)
- app.pipeline.source_bundle(app.scheduler, dependencies, force, track,
+ app.pipeline.source_bundle(app.scheduler, dependencies, force, track_,
compression, directory)
click.echo("", err=True)
except BstError as e:
@@ -606,18 +606,18 @@ def workspace():
help="Do not checkout the source, only link to the given directory")
@click.option('--force', '-f', default=False, is_flag=True,
help="Overwrite files existing in checkout directory")
-@click.option('--track', default=False, is_flag=True,
+@click.option('--track', 'track_', default=False, is_flag=True,
help="Track and fetch new source references before checking out the workspace")
@click.argument('element',
type=click.Path(dir_okay=False, readable=True))
@click.argument('directory', type=click.Path(file_okay=False))
@click.pass_obj
-def workspace_open(app, no_checkout, force, track, element, directory):
+def workspace_open(app, no_checkout, force, track_, element, directory):
"""Open a workspace for manual source modification"""
- app.initialize((element,), rewritable=track, track_elements=[element] if track else None)
+ app.initialize((element,), rewritable=track_, track_elements=[element] if track_ else None)
try:
- app.pipeline.open_workspace(app.scheduler, directory, no_checkout, track, force)
+ app.pipeline.open_workspace(app.scheduler, directory, no_checkout, track_, force)
click.echo("", err=True)
except BstError as e:
app.print_error(e)
@@ -660,14 +660,14 @@ def workspace_close(app, remove_dir, element):
# Workspace Reset Command #
##################################################################
@workspace.command(name='reset', short_help="Reset a workspace to its original state")
-@click.option('--track', default=False, is_flag=True,
+@click.option('--track', 'track_', default=False, is_flag=True,
help="Track and fetch the latest source before resetting")
@click.option('--no-checkout', default=False, is_flag=True,
help="Do not checkout the source, only link to the given directory")
@click.argument('element',
type=click.Path(dir_okay=False, readable=True))
@click.pass_obj
-def workspace_reset(app, track, no_checkout, element):
+def workspace_reset(app, track_, no_checkout, element):
"""Reset a workspace to its original state"""
app.initialize((element,))
if app.interactive:
@@ -676,7 +676,7 @@ def workspace_reset(app, track, no_checkout, element):
sys.exit(-1)
try:
- app.pipeline.reset_workspace(app.scheduler, track, no_checkout)
+ app.pipeline.reset_workspace(app.scheduler, track_, no_checkout)
click.echo("", err=True)
except BstError as e:
click.echo("", err=True)
@@ -714,12 +714,12 @@ def workspace_list(app):
workspaces = []
for element_name, directory in project._list_workspaces():
- workspace = {
+ workspace_ = {
'element': element_name,
'directory': directory,
}
- workspaces.append(workspace)
+ workspaces.append(workspace_)
_yaml.dump({
'workspaces': workspaces
diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py
index c68f1df39..90e207ed3 100644
--- a/buildstream/_frontend/widget.py
+++ b/buildstream/_frontend/widget.py
@@ -637,12 +637,12 @@ class LogLine(Widget):
return text
- def show_pipeline(self, dependencies, format):
+ def show_pipeline(self, dependencies, format_):
report = ''
p = Profile()
for element in dependencies:
- line = format
+ line = format_
full_key, cache_key, dim_keys = element._get_full_display_key()
@@ -666,41 +666,41 @@ class LogLine(Widget):
line = p.fmt_subst(line, 'state', "waiting", fg='blue')
# Element configuration
- if "%{config" in format:
+ if "%{config" in format_:
config = _yaml.node_sanitize(element._Element__config)
line = p.fmt_subst(
line, 'config',
yaml.round_trip_dump(config, default_flow_style=False, allow_unicode=True))
# Variables
- if "%{vars" in format:
+ if "%{vars" in format_:
variables = _yaml.node_sanitize(element._Element__variables.variables)
line = p.fmt_subst(
line, 'vars',
yaml.round_trip_dump(variables, default_flow_style=False, allow_unicode=True))
# Environment
- if "%{env" in format:
+ if "%{env" in format_:
environment = _yaml.node_sanitize(element._Element__environment)
line = p.fmt_subst(
line, 'env',
yaml.round_trip_dump(environment, default_flow_style=False, allow_unicode=True))
# Public
- if "%{public" in format:
+ if "%{public" in format_:
environment = _yaml.node_sanitize(element._Element__public)
line = p.fmt_subst(
line, 'public',
yaml.round_trip_dump(environment, default_flow_style=False, allow_unicode=True))
# Workspaced
- if "%{workspaced" in format:
+ if "%{workspaced" in format_:
line = p.fmt_subst(
line, 'workspaced',
'(workspaced)' if element._workspaced() else '', fg='yellow')
# Workspace-dirs
- if "%{workspace-dirs" in format:
+ if "%{workspace-dirs" in format_:
dirs = [path.replace(os.getenv('HOME', '/root'), '~')
for path in element._workspace_dirs()]
if dirs:
diff --git a/buildstream/_ostree.py b/buildstream/_ostree.py
index a1f01aa96..0abb51da8 100644
--- a/buildstream/_ostree.py
+++ b/buildstream/_ostree.py
@@ -77,10 +77,10 @@ def ensure(path, compress):
# Args:
# repo (OSTree.Repo): The repo
# path (str): The checkout path
-# commit (str): The commit checksum to checkout
+# commit_ (str): The commit checksum to checkout
# user (boot): Whether to checkout in user mode
#
-def checkout(repo, path, commit, user=False):
+def checkout(repo, path, commit_, user=False):
# Check out a full copy of an OSTree at a given ref to some directory.
#
@@ -111,9 +111,9 @@ def checkout(repo, path, commit, user=False):
# current working directory.
AT_FDCWD = -100
try:
- repo.checkout_at(options, AT_FDCWD, path, commit)
+ repo.checkout_at(options, AT_FDCWD, path, commit_)
except GLib.GError as e:
- raise OSTreeError("Failed to checkout commit '{}': {}".format(commit, e.message)) from e
+ raise OSTreeError("Failed to checkout commit '{}': {}".format(commit_, e.message)) from e
# commit():
@@ -124,10 +124,10 @@ def checkout(repo, path, commit, user=False):
#
# Args:
# repo (OSTree.Repo): The repo
-# dir (str): The source directory to commit to the repo
+# dir_ (str): The source directory to commit to the repo
# refs (list): A list of symbolic references (tag) for the commit
#
-def commit(repo, dir, refs):
+def commit(repo, dir_, refs):
def commit_filter(repo, path, file_info):
@@ -148,7 +148,7 @@ def commit(repo, dir, refs):
try:
# add tree to repository
mtree = OSTree.MutableTree.new()
- repo.write_directory_to_mtree(Gio.File.new_for_path(dir),
+ repo.write_directory_to_mtree(Gio.File.new_for_path(dir_),
mtree, commit_modifier)
_, root = repo.write_mtree(mtree)
@@ -239,8 +239,8 @@ def exists(repo, ref):
#
def checksum(repo, ref):
- _, checksum = repo.resolve_rev(ref, True)
- return checksum
+ _, checksum_ = repo.resolve_rev(ref, True)
+ return checksum_
# fetch()
diff --git a/buildstream/_profile.py b/buildstream/_profile.py
index 7dd7fbb67..0bf4a3dcd 100644
--- a/buildstream/_profile.py
+++ b/buildstream/_profile.py
@@ -69,11 +69,11 @@ class Profile():
with open(filename, "a", encoding="utf-8") as f:
dt = datetime.datetime.fromtimestamp(self.start)
- time = dt.strftime('%Y-%m-%d %H:%M:%S')
+ time_ = dt.strftime('%Y-%m-%d %H:%M:%S')
heading = '================================================================\n'
heading += 'Profile for key: {}\n'.format(self.key)
- heading += 'Started at: {}\n'.format(time)
+ heading += 'Started at: {}\n'.format(time_)
if self.message:
heading += '\n {}'.format(self.message)
heading += '================================================================\n'
diff --git a/buildstream/_signals.py b/buildstream/_signals.py
index 30af75b36..9749e0d1a 100644
--- a/buildstream/_signals.py
+++ b/buildstream/_signals.py
@@ -33,11 +33,11 @@ suspendable_stack = deque()
# Per process SIGTERM handler
-def terminator_handler(signal, frame):
+def terminator_handler(signal_, frame):
while terminator_stack:
- terminator = terminator_stack.pop()
+ terminator_ = terminator_stack.pop()
try:
- terminator()
+ terminator_()
except: # pylint: disable=bare-except
# Ensure we print something if there's an exception raised when
# processing the handlers. Note that the default exception
@@ -46,7 +46,7 @@ def terminator_handler(signal, frame):
# clause.
traceback.print_exc(file=sys.stderr)
print('Error encountered in BuildStream while processing custom SIGTERM handler:',
- terminator,
+ terminator_,
file=sys.stderr)
# Use special exit here, terminate immediately, recommended
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py
index 718f7321b..a597962ff 100644
--- a/buildstream/_yaml.py
+++ b/buildstream/_yaml.py
@@ -20,7 +20,7 @@
import sys
import collections
-import copy
+from copy import deepcopy
from contextlib import ExitStack
from ruamel import yaml
@@ -238,7 +238,7 @@ def dump(node, filename=None):
#
def node_decorated_copy(filename, toplevel, copy_tree=False):
if copy_tree:
- result = copy.deepcopy(toplevel)
+ result = deepcopy(toplevel)
else:
result = toplevel
diff --git a/buildstream/utils.py b/buildstream/utils.py
index a0c5eeba7..bccd5fc68 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -822,7 +822,7 @@ def _set_deterministic_mtime(directory):
# supports cleaning up the temp directory on SIGTERM.
#
@contextmanager
-def _tempdir(suffix="", prefix="tmp", dir=None):
+def _tempdir(suffix="", prefix="tmp", dir=None): # pylint: disable=redefined-builtin
tempdir = tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dir)
def cleanup_tempdir():