mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
🎨 Format Python code with Black
This commit is contained in:
parent
ccc005fb84
commit
ea6eaa6b1e
4 changed files with 18 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue