From ea6eaa6b1e3aed941260e880da955087b3a8ea91 Mon Sep 17 00:00:00 2001 From: alexAubin Date: Tue, 28 Dec 2021 23:46:17 +0000 Subject: [PATCH] :art: Format Python code with Black --- moulinette/actionsmap.py | 4 +++- moulinette/interfaces/__init__.py | 5 ++--- moulinette/interfaces/api.py | 12 +++++++----- test/test_actionsmap.py | 10 ++++++---- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/moulinette/actionsmap.py b/moulinette/actionsmap.py index 62ae5ca1..cf7c9944 100644 --- a/moulinette/actionsmap.py +++ b/moulinette/actionsmap.py @@ -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 diff --git a/moulinette/interfaces/__init__.py b/moulinette/interfaces/__init__.py index eeb0a97a..d7753eae 100644 --- a/moulinette/interfaces/__init__.py +++ b/moulinette/interfaces/__init__.py @@ -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) diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index 7ce813ee..abc0fd93 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -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() diff --git a/test/test_actionsmap.py b/test/test_actionsmap.py index 02cf8166..10ce4795 100644 --- a/test/test_actionsmap.py +++ b/test/test_actionsmap.py @@ -192,10 +192,12 @@ 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( - "ask", - "foo", - "parameter value must be a string, got 1", + 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)