From 670f4e61d1c00130c2f83ce24736c2faaeb95166 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Mon, 1 May 2017 11:02:28 +0200 Subject: [PATCH 1/2] fixing codacy issues --- bonobo/commands/init.py | 4 +--- bonobo/commands/run.py | 4 ++-- bonobo/config/configurables.py | 2 +- bonobo/config/processors.py | 6 +++--- bonobo/ext/edgy/project/feature.py | 4 ---- bonobo/ext/jupyter/plugin.py | 8 -------- bonobo/io/csv.py | 2 +- tests/io/test_file.py | 2 +- tests/test_commands.py | 2 +- 9 files changed, 10 insertions(+), 24 deletions(-) diff --git a/bonobo/commands/init.py b/bonobo/commands/init.py index a1ab700..55c4b6b 100644 --- a/bonobo/commands/init.py +++ b/bonobo/commands/init.py @@ -3,14 +3,12 @@ import os def execute(): try: - import edgy.project + from edgy.project.__main__ import handle_init except ImportError as exc: raise ImportError( 'You must install "edgy.project" to use this command.\n\n $ pip install edgy.project\n' ) from exc - from edgy.project.__main__ import handle_init - return handle_init(os.path.join(os.getcwd(), 'Projectfile')) diff --git a/bonobo/commands/run.py b/bonobo/commands/run.py index 62f15c4..b7872e2 100644 --- a/bonobo/commands/run.py +++ b/bonobo/commands/run.py @@ -20,7 +20,7 @@ def get_default_services(filename, services=None): } try: exec(code, context) - except Exception as exc: + except Exception: raise return { **context[DEFAULT_SERVICES_ATTR](), @@ -55,7 +55,7 @@ def execute(file, quiet=False): 'but it is something that will be implemented in the future.\n\nExpected: 1, got: {}.' ).format(len(graphs)) - name, graph = list(graphs.items())[0] + graph = list(graphs.values())[0] # todo if console and not quiet, then add the console plugin # todo when better console plugin, add it if console and just disable display diff --git a/bonobo/config/configurables.py b/bonobo/config/configurables.py index d5bdeb3..e3ad2cf 100644 --- a/bonobo/config/configurables.py +++ b/bonobo/config/configurables.py @@ -53,4 +53,4 @@ class Configurable(metaclass=ConfigurableMeta): ) for name, value in kwargs.items(): - setattr(self, name, kwargs[name]) + setattr(self, name, value) diff --git a/bonobo/config/processors.py b/bonobo/config/processors.py index 64a4bee..9dac6d0 100644 --- a/bonobo/config/processors.py +++ b/bonobo/config/processors.py @@ -52,9 +52,9 @@ def contextual(cls_or_func): setattr(cls_or_func, _CONTEXT_PROCESSORS_ATTR, []) _processors = getattr(cls_or_func, _CONTEXT_PROCESSORS_ATTR) - for name, value in cls_or_func.__dict__.items(): - if isinstance(value, ContextProcessor): - _processors.append(value) + for processor in cls_or_func.__dict__.values(): + if isinstance(processor, ContextProcessor): + _processors.append(processor) # This is needed for python 3.5, python 3.6 should be fine, but it's considered an implementation detail. _processors.sort(key=lambda proc: proc._creation_counter) diff --git a/bonobo/ext/edgy/project/feature.py b/bonobo/ext/edgy/project/feature.py index ef75fea..5a01f97 100644 --- a/bonobo/ext/edgy/project/feature.py +++ b/bonobo/ext/edgy/project/feature.py @@ -14,10 +14,6 @@ from edgy.project.feature import Feature, SUPPORT_PRIORITY class BonoboFeature(Feature): requires = {'python'} - @subscribe('edgy.project.feature.make.on_generate', priority=SUPPORT_PRIORITY) - def on_make_generate(self, event): - makefile = event.makefile - @subscribe('edgy.project.on_start', priority=SUPPORT_PRIORITY) def on_start(self, event): package_path = event.setup['name'].replace('.', os.sep) diff --git a/bonobo/ext/jupyter/plugin.py b/bonobo/ext/jupyter/plugin.py index c49610d..fe907be 100644 --- a/bonobo/ext/jupyter/plugin.py +++ b/bonobo/ext/jupyter/plugin.py @@ -24,11 +24,3 @@ class JupyterOutputPlugin(Plugin): finalize = run -""" -TODO JUPYTER WIDGET -################### - -# close the widget? what does it do? -https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Basics.html#Closing-widgets - -""" diff --git a/bonobo/io/csv.py b/bonobo/io/csv.py index 9192fc3..4922b43 100644 --- a/bonobo/io/csv.py +++ b/bonobo/io/csv.py @@ -50,7 +50,7 @@ class CsvReader(CsvHandler, FileReader): field_count = len(headers.value) if self.skip and self.skip > 0: - for i in range(0, self.skip): + for _ in range(0, self.skip): next(reader) for row in reader: diff --git a/tests/io/test_file.py b/tests/io/test_file.py index dc011a1..918b27f 100644 --- a/tests/io/test_file.py +++ b/tests/io/test_file.py @@ -21,7 +21,7 @@ def test_file_writer_in_context(tmpdir, lines, output): context.start() context.recv(BEGIN, *map(Bag, lines), END) - for i in range(len(lines)): + for _ in range(len(lines)): context.step() context.stop() diff --git a/tests/test_commands.py b/tests/test_commands.py index 8c33c6d..55032b2 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -18,7 +18,7 @@ def test_entrypoint(): def test_no_command(capsys): with pytest.raises(SystemExit): entrypoint([]) - out, err = capsys.readouterr() + _, err = capsys.readouterr() assert 'error: the following arguments are required: command' in err From e04a6261d016507f1ea3a20bc8cd5175a41891c8 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Mon, 1 May 2017 11:06:17 +0200 Subject: [PATCH 2/2] codacy config --- .codacy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.codacy.yml b/.codacy.yml index 9254b5f..390e58f 100644 --- a/.codacy.yml +++ b/.codacy.yml @@ -1,4 +1,4 @@ --- exclude_paths: - - bonobo/examples - - bonobo/ext + - bonobo/examples/ + - bonobo/ext/