From a7fe3ed6089cf00303e777ea5bac581d84c60d67 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Tue, 19 Dec 2023 21:23:28 +0100 Subject: [PATCH] apply new linter --- data_encryption/models/encrypted_data.py | 8 ++++---- server_environment/server_env.py | 6 ++++-- .../models/server_env_mixin.py | 12 +++--------- .../models/ir_config_parameter.py | 1 - 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/data_encryption/models/encrypted_data.py b/data_encryption/models/encrypted_data.py index d9dbc676..c1ea7a7d 100644 --- a/data_encryption/models/encrypted_data.py +++ b/data_encryption/models/encrypted_data.py @@ -44,14 +44,14 @@ def _decrypt_data(self, env): cipher = self._get_cipher(env) try: return cipher.decrypt(self.encrypted_data).decode() - except InvalidToken: + except InvalidToken as err: raise ValidationError( _( "Password has been encrypted with a different " "key. Unless you can recover the previous key, " "this password is unreadable." ) - ) + ) from err @api.model @ormcache("self._uid", "name", "env") @@ -77,10 +77,10 @@ def _encrypted_read_json(self, name, env=None): return {} try: return json.loads(data) - except (ValueError, TypeError): + except (ValueError, TypeError) as err: raise ValidationError( _("The data you are trying to read are not in a json format") - ) + ) from err @staticmethod def _retrieve_env(): diff --git a/server_environment/server_env.py b/server_environment/server_env.py index c20654c7..3ea690e2 100644 --- a/server_environment/server_env.py +++ b/server_environment/server_env.py @@ -118,7 +118,9 @@ def _load_config_from_server_env_files(config_p): try: config_p.read(conf_files) except Exception as e: - raise Exception('Cannot read config files "{}": {}'.format(conf_files, e)) + raise Exception( + 'Cannot read config files "{}": {}'.format(conf_files, e) + ) from e def _load_config_from_rcfile(config_p): @@ -135,7 +137,7 @@ def _load_config_from_env(config_p): except configparser.Error as err: raise Exception( "{} content could not be parsed: {}".format(varname, err) - ) + ) from err def _load_config(): diff --git a/server_environment_data_encryption/models/server_env_mixin.py b/server_environment_data_encryption/models/server_env_mixin.py index 11ada9f5..b3ceb4ee 100644 --- a/server_environment_data_encryption/models/server_env_mixin.py +++ b/server_environment_data_encryption/models/server_env_mixin.py @@ -105,9 +105,7 @@ def _get_extra_environment_info_div(self, current_env, extra_envs): {} - """.format( - "alert-danger", warning_string - ) + """.format("alert-danger", warning_string) ) return elem @@ -120,9 +118,7 @@ def _get_extra_environment_info_div(self, current_env, extra_envs): type="object" string="{}{}" class="btn btn-lg btn-primary ml-2" context="{}"/> - """.format( - button_string, environment, {"environment": environment} - ) + """.format(button_string, environment, {"environment": environment}) button_div += "{}".format(button) button_div += "" alert_string = _("Modify values for {} environment").format(current_env) @@ -137,9 +133,7 @@ def _get_extra_environment_info_div(self, current_env, extra_envs): {} - """.format( - alert_type, alert_string, button_div - ) + """.format(alert_type, alert_string, button_div) ) return elem diff --git a/server_environment_ir_config_parameter/models/ir_config_parameter.py b/server_environment_ir_config_parameter/models/ir_config_parameter.py index 21bf67f5..bdeebe72 100644 --- a/server_environment_ir_config_parameter/models/ir_config_parameter.py +++ b/server_environment_ir_config_parameter/models/ir_config_parameter.py @@ -10,7 +10,6 @@ class IrConfigParameter(models.Model): - _inherit = "ir.config_parameter" is_environment = fields.Boolean(