🎨 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) actionsmap = read_yaml(actionsmap_yml)
# Delete old cache files # 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) os.remove(old_cache)
# at installation, cachedir might not exists # at installation, cachedir might not exists

View file

@ -224,9 +224,8 @@ class _CallbackAction(argparse.Action):
# Execute callback and get returned value # Execute callback and get returned value
value = self.callback(namespace, values, **self.callback_kwargs) value = self.callback(namespace, values, **self.callback_kwargs)
except Exception as e: except Exception as e:
error_message = ( error_message = "cannot get value from callback method " "'{}': {}".format(
"cannot get value from callback method " self.callback_method, e
"'{}': {}".format(self.callback_method, e)
) )
logger.exception(error_message) logger.exception(error_message)
raise MoulinetteError(error_message, raw_msg=True) 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... # We define a global variable to manage in a dirty way the upload...
UPLOAD_DIR = None UPLOAD_DIR = None
CSRF_TYPES = { CSRF_TYPES = {"text/plain", "application/x-www-form-urlencoded", "multipart/form-data"}
"text/plain", "application/x-www-form-urlencoded", "multipart/form-data"
}
def is_csrf(): def is_csrf():
@ -667,7 +665,9 @@ class ActionsMapParser(BaseActionsMapParser):
# Retrieve the tid for the route # Retrieve the tid for the route
_, parser = self._parsers[route] _, parser = self._parsers[route]
except KeyError as e: 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) logger.error(error_message)
raise MoulinetteValidationError(error_message, raw_msg=True) raise MoulinetteValidationError(error_message, raw_msg=True)
@ -684,7 +684,9 @@ class ActionsMapParser(BaseActionsMapParser):
# Retrieve the parser for the route # Retrieve the parser for the route
_, parser = self._parsers[route] _, parser = self._parsers[route]
except KeyError as e: 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) logger.error(error_message)
raise MoulinetteValidationError(error_message, raw_msg=True) raise MoulinetteValidationError(error_message, raw_msg=True)
ret = argparse.Namespace() ret = argparse.Namespace()

View file

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