🎨 Format Python code with Black

This commit is contained in:
alexAubin 2021-12-28 23:46:17 +00:00 committed by GitHub
parent ccc005fb84
commit ea6eaa6b1e
4 changed files with 18 additions and 13 deletions

View file

@ -428,7 +428,9 @@ class ActionsMap:
actionsmap = read_yaml(actionsmap_yml)
# Delete old cache files
for old_cache in glob.glob("{}/actionsmap/{}-*.pkl".format(CACHE_DIR, n)):
for old_cache in glob.glob(
"{}/actionsmap/{}-*.pkl".format(CACHE_DIR, n)
):
os.remove(old_cache)
# at installation, cachedir might not exists

View file

@ -224,9 +224,8 @@ class _CallbackAction(argparse.Action):
# Execute callback and get returned value
value = self.callback(namespace, values, **self.callback_kwargs)
except Exception as e:
error_message = (
"cannot get value from callback method "
"'{}': {}".format(self.callback_method, e)
error_message = "cannot get value from callback method " "'{}': {}".format(
self.callback_method, e
)
logger.exception(error_message)
raise MoulinetteError(error_message, raw_msg=True)

View file

@ -38,9 +38,7 @@ logger = log.getLogger("moulinette.interface.api")
# We define a global variable to manage in a dirty way the upload...
UPLOAD_DIR = None
CSRF_TYPES = {
"text/plain", "application/x-www-form-urlencoded", "multipart/form-data"
}
CSRF_TYPES = {"text/plain", "application/x-www-form-urlencoded", "multipart/form-data"}
def is_csrf():
@ -667,7 +665,9 @@ class ActionsMapParser(BaseActionsMapParser):
# Retrieve the tid for the route
_, parser = self._parsers[route]
except KeyError as e:
error_message = "no argument parser found for route '{}': {}".format(route, e)
error_message = "no argument parser found for route '{}': {}".format(
route, e
)
logger.error(error_message)
raise MoulinetteValidationError(error_message, raw_msg=True)
@ -684,7 +684,9 @@ class ActionsMapParser(BaseActionsMapParser):
# Retrieve the parser for the route
_, parser = self._parsers[route]
except KeyError as e:
error_message = "no argument parser found for route '{}': {}".format(route, e)
error_message = "no argument parser found for route '{}': {}".format(
route, e
)
logger.error(error_message)
raise MoulinetteValidationError(error_message, raw_msg=True)
ret = argparse.Namespace()

View file

@ -192,11 +192,13 @@ def test_extra_argument_parser_add_argument_bad_arg(iface):
with pytest.raises(MoulinetteError) as exception:
extra_argument_parse.add_argument("_global", "foo", {"ask": 1})
expected_msg = "unable to validate extra parameter '{}' for argument '{}': {}".format(
expected_msg = (
"unable to validate extra parameter '{}' for argument '{}': {}".format(
"ask",
"foo",
"parameter value must be a string, got 1",
)
)
assert expected_msg in str(exception)
extra_argument_parse = ExtraArgumentParser(iface)