diff --git a/bonobo/config/services.py b/bonobo/config/services.py index 107130e..a15ee12 100644 --- a/bonobo/config/services.py +++ b/bonobo/config/services.py @@ -79,7 +79,9 @@ class Container(dict): if not name in self: if default: return default - raise MissingServiceImplementationError('Cannot resolve service {!r} using provided service collection.'.format(name)) + raise MissingServiceImplementationError( + 'Cannot resolve service {!r} using provided service collection.'.format(name) + ) value = super().get(name) if isinstance(value, types.LambdaType): value = value(self) diff --git a/bonobo/errors.py b/bonobo/errors.py index cdb4db5..564950d 100644 --- a/bonobo/errors.py +++ b/bonobo/errors.py @@ -57,5 +57,6 @@ class ProhibitedOperationError(RuntimeError): class ConfigurationError(Exception): pass + class MissingServiceImplementationError(KeyError): - pass \ No newline at end of file + pass diff --git a/bonobo/execution/base.py b/bonobo/execution/base.py index cefde32..779f212 100644 --- a/bonobo/execution/base.py +++ b/bonobo/execution/base.py @@ -8,6 +8,7 @@ from bonobo.plugins import get_enhancers from bonobo.util.errors import print_error from bonobo.util.objects import Wrapper, get_name + @contextmanager def recoverable(error_handler): try: @@ -15,6 +16,7 @@ def recoverable(error_handler): except Exception as exc: # pylint: disable=broad-except error_handler(exc, traceback.format_exc()) + @contextmanager def unrecoverable(error_handler): try: @@ -23,6 +25,7 @@ def unrecoverable(error_handler): error_handler(exc, traceback.format_exc()) raise # raise unrecoverableerror from x ? + class LoopingExecutionContext(Wrapper): alive = True PERIOD = 0.25 diff --git a/bonobo/nodes/basics.py b/bonobo/nodes/basics.py index 025b99f..5ce550c 100644 --- a/bonobo/nodes/basics.py +++ b/bonobo/nodes/basics.py @@ -73,7 +73,7 @@ def _count_counter(self, context): class PrettyPrinter(Configurable): def call(self, *args, **kwargs): for i, (item, value) in enumerate(itertools.chain(enumerate(args), kwargs.items())): - print(' ' if i else '•', item, '=', str(value).strip().replace('\n', '\n'+CLEAR_EOL), CLEAR_EOL) + print(' ' if i else '•', item, '=', str(value).strip().replace('\n', '\n' + CLEAR_EOL), CLEAR_EOL) pprint = Tee(_pprint) diff --git a/bonobo/util/errors.py b/bonobo/util/errors.py index 3160926..0ea4e58 100644 --- a/bonobo/util/errors.py +++ b/bonobo/util/errors.py @@ -37,11 +37,10 @@ def print_error(exc, trace, context=None, method=None): ' (in {}{})'.format(type(context).__name__, '.{}()'.format(method) if method else '') if context else '', Style.RESET_ALL, '\n', - indent(_get_error_message(exc), prefix+Style.BRIGHT), + indent(_get_error_message(exc), prefix + Style.BRIGHT), Style.RESET_ALL, sep='', file=sys.stderr, ) print(prefix, file=sys.stderr) print(indent(trace, prefix, predicate=lambda line: True), file=sys.stderr) - diff --git a/setup.py b/setup.py index 81f2be3..feabb8c 100644 --- a/setup.py +++ b/setup.py @@ -42,43 +42,41 @@ else: setup( name='bonobo', - description= - ('Bonobo, a simple, modern and atomic extract-transform-load toolkit for ' - 'python 3.5+.'), + description=('Bonobo, a simple, modern and atomic extract-transform-load toolkit for ' + 'python 3.5+.'), license='Apache License, Version 2.0', install_requires=[ - 'colorama >=0.3,<1.0', 'fs >=2.0,<3.0', 'psutil >=5.2,<6.0', - 'requests >=2.0,<3.0', 'stevedore >=1.21,<2.0' + 'colorama >=0.3,<1.0', 'fs >=2.0,<3.0', 'psutil >=5.2,<6.0', 'requests >=2.0,<3.0', 'stevedore >=1.21,<2.0' ], version=version, long_description=long_description, classifiers=classifiers, packages=find_packages(exclude=['ez_setup', 'example', 'test']), include_package_data=True, - data_files=[('share/jupyter/nbextensions/bonobo-jupyter', [ - 'bonobo/ext/jupyter/static/extension.js', - 'bonobo/ext/jupyter/static/index.js', - 'bonobo/ext/jupyter/static/index.js.map' - ])], + data_files=[ + ( + 'share/jupyter/nbextensions/bonobo-jupyter', [ + 'bonobo/ext/jupyter/static/extension.js', 'bonobo/ext/jupyter/static/index.js', + 'bonobo/ext/jupyter/static/index.js.map' + ] + ) + ], extras_require={ 'dev': [ - 'coverage >=4,<5', 'pylint >=1,<2', 'pytest >=3,<4', - 'pytest-cov >=2,<3', 'pytest-timeout >=1,<2', 'sphinx', + 'coverage >=4,<5', 'pylint >=1,<2', 'pytest >=3,<4', 'pytest-cov >=2,<3', 'pytest-timeout >=1,<2', 'sphinx', 'sphinx_rtd_theme', 'yapf' ], 'jupyter': ['jupyter >=1.0,<1.1', 'ipywidgets >=6.0.0.beta5'] }, entry_points={ 'bonobo.commands': [ - 'init = bonobo.commands.init:register', - 'run = bonobo.commands.run:register', + 'init = bonobo.commands.init:register', 'run = bonobo.commands.run:register', 'version = bonobo.commands.version:register' ], 'console_scripts': ['bonobo = bonobo.commands:entrypoint'], - 'edgy.project.features': - ['bonobo = ' - 'bonobo.ext.edgy.project.feature:BonoboFeature'] + 'edgy.project.features': ['bonobo = ' + 'bonobo.ext.edgy.project.feature:BonoboFeature'] }, url='https://www.bonobo-project.org/', - download_url='https://github.com/python-bonobo/bonobo/tarball/{version}'. - format(version=version), ) + download_url='https://github.com/python-bonobo/bonobo/tarball/{version}'.format(version=version), +) diff --git a/tests/test_commands.py b/tests/test_commands.py index 66ca6e3..a8cd5b1 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1,7 +1,11 @@ +import runpy +import sys +from unittest.mock import patch + import pkg_resources import pytest -from bonobo import __version__, get_examples_path +from bonobo import __main__, __version__, get_examples_path from bonobo.commands import entrypoint @@ -10,7 +14,8 @@ def runner_entrypoint(*args): def runner_module(*args): - return entrypoint(list(args)) + with patch.object(sys, 'argv', ['bonobo', *args]): + return runpy.run_path(__main__.__file__, run_name='__main__') all_runners = pytest.mark.parametrize('runner', [runner_entrypoint, runner_module])