Minor tweaks about code quality.

This commit is contained in:
Romain Dorgueil
2018-07-16 10:00:28 +02:00
parent d9f2fd3009
commit 6a1203602f
9 changed files with 9 additions and 15 deletions

View File

@ -72,7 +72,7 @@ class ConfigurableMeta(type):
try:
import _functools
except:
except ImportError:
import functools
PartiallyConfigured = functools.partial

View File

@ -1,5 +1,3 @@
import inspect
import pprint
import re
import threading
import types

View File

@ -51,7 +51,7 @@ if __name__ == '__main__':
s3.head_object(
Bucket='bonobo-examples', Key=s3_path
)
except:
except Exception:
s3.upload_file(
local_path,
'bonobo-examples',

View File

@ -1,7 +1,6 @@
import logging
import sys
from contextlib import contextmanager
from logging import ERROR
from bonobo.util import deprecated
from bonobo.util.objects import Wrapper, get_name
@ -13,7 +12,7 @@ def recoverable(error_handler):
try:
yield
except Exception as exc: # pylint: disable=broad-except
error_handler(*sys.exc_info(), level=ERROR)
error_handler(*sys.exc_info(), level=logging.ERROR)
@contextmanager
@ -21,7 +20,7 @@ def unrecoverable(error_handler):
try:
yield
except Exception as exc: # pylint: disable=broad-except
error_handler(*sys.exc_info(), level=ERROR)
error_handler(*sys.exc_info(), level=logging.ERROR)
raise # raise unrecoverableerror from exc ?

View File

@ -29,7 +29,7 @@ class ExecutorStrategy(Strategy):
with self.create_executor() as executor:
try:
context.start(self.get_starter(executor, futures))
except:
except Exception:
logger.critical('Exception caught while starting execution context.', exc_info=sys.exc_info())
while context.alive:
@ -53,14 +53,14 @@ class ExecutorStrategy(Strategy):
try:
with node:
node.loop()
except:
except Exception:
logging.getLogger(__name__).critical(
'Critical error in threadpool node starter.', exc_info=sys.exc_info()
)
try:
futures.append(executor.submit(_runner))
except:
except Exception:
logging.getLogger(__name__).critical('futures.append', exc_info=sys.exc_info())
return starter

View File

@ -1,12 +1,11 @@
import csv
from bonobo.config import Option, use_raw_input, use_context
from bonobo.config import Option, use_context
from bonobo.config.options import Method, RenamedOption
from bonobo.constants import NOT_MODIFIED
from bonobo.nodes.io.base import FileHandler
from bonobo.nodes.io.file import FileReader, FileWriter
from bonobo.util import ensure_tuple
from bonobo.util.bags import BagType
class CsvHandler(FileHandler):

View File

@ -1,5 +1,4 @@
from bonobo.plugins import Plugin
from raven import Client
class SentryPlugin(Plugin):

View File

@ -52,7 +52,7 @@ class Setting:
def set(self, value):
value = self.formatter(value) if self.formatter else value
if self.validator and not self.validator(value):
raise ValidationError('Invalid value {!r} for setting {}.'.format(value, self.name))
raise ValidationError(self, 'Invalid value {!r} for setting {!r}.'.format(value, self.name))
self.value = value
def set_if_true(self, value):

View File

@ -57,7 +57,6 @@ def get_argument_parser(parser=None):
:return:
"""
if parser is None:
import argparse
parser = argparse.ArgumentParser()
# Store globally to be able to warn the user about the fact he's probably wrong not to pass a parser to