From a9e4d6b1025ae6bf2de10795678d716883927223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Todorovich?= Date: Wed, 20 May 2026 09:50:57 -0300 Subject: [PATCH] pre-commit run -a --- attachment_azure/models/ir_attachment.py | 8 ++++---- .../models/ir_attachment.py | 14 +++++++------- base_attachment_object_storage/models/strtobool.py | 2 +- cloud_platform/models/cloud_platform.py | 4 ++-- cloud_platform/models/strtobool.py | 2 +- cloud_platform_azure/{README.md => README.rst} | 3 ++- cloud_platform_azure/models/cloud_platform.py | 5 ++--- kwkhtmltopdf_assets/models/ir_qweb.py | 1 - logging_json/json_log.py | 2 +- logging_json/strtobool.py | 2 +- monitoring_status/controllers/main.py | 1 - session_redis/http.py | 5 ++--- session_redis/session.py | 4 ++-- session_redis/strtobool.py | 2 +- 14 files changed, 26 insertions(+), 29 deletions(-) rename cloud_platform_azure/{README.md => README.rst} (68%) diff --git a/attachment_azure/models/ir_attachment.py b/attachment_azure/models/ir_attachment.py index fd15a21..2662a63 100644 --- a/attachment_azure/models/ir_attachment.py +++ b/attachment_azure/models/ir_attachment.py @@ -32,7 +32,7 @@ class IrAttachment(models.Model): _inherit = "ir.attachment" def _get_stores(self): - return ["azure"] + super(IrAttachment, self)._get_stores() + return ["azure"] + super()._get_stores() @api.model def _get_blob_service_client(self): @@ -162,7 +162,7 @@ class IrAttachment(models.Model): _logger.info("Attachment '%s' missing on object storage", fname) return read else: - return super(IrAttachment, self)._store_file_read(fname, bin_size) + return super()._store_file_read(fname, bin_size) @api.model def _store_file_write(self, key, bin_data): @@ -189,7 +189,7 @@ class IrAttachment(models.Model): _("The file could not be stored: %s") % str(error) ) from None else: - _super = super(IrAttachment, self) + _super = super() filename = _super._store_file_write(key, bin_data) return filename @@ -215,4 +215,4 @@ class IrAttachment(models.Model): # user _logger.exception("Error during deletion of the file %s" % fname) else: - super(IrAttachment, self)._store_file_delete(fname) + super()._store_file_delete(fname) diff --git a/base_attachment_object_storage/models/ir_attachment.py b/base_attachment_object_storage/models/ir_attachment.py index e8b17f5..c84530d 100644 --- a/base_attachment_object_storage/models/ir_attachment.py +++ b/base_attachment_object_storage/models/ir_attachment.py @@ -33,7 +33,7 @@ def clean_fs(files): _logger.info( "_file_delete could not unlink %s", full_path, exc_info=True ) - except IOError: + except OSError: # Harmless and needed for race conditions _logger.info( "_file_delete could not unlink %s", full_path, exc_info=True @@ -124,7 +124,7 @@ class IrAttachment(models.Model): domain = [] storage_config = self._get_storage_force_db_config() for mimetype_key, limit in storage_config.items(): - part = [("mimetype", "=like", "{}%".format(mimetype_key))] + part = [("mimetype", "=like", f"{mimetype_key}%")] if limit: part = AND([part, [("file_size", "<=", limit)]]) domain = OR([domain, part]) @@ -236,7 +236,7 @@ class IrAttachment(models.Model): # using SQL to include files hidden through unlink or due to record # rules cr.execute( - "SELECT COUNT(*) FROM ir_attachment " "WHERE store_fname = %s", (fname,) + "SELECT COUNT(*) FROM ir_attachment WHERE store_fname = %s", (fname,) ) count = cr.fetchone()[0] if not count: @@ -249,7 +249,7 @@ class IrAttachment(models.Model): for store_name in self._get_stores(): if self.is_storage_disabled(store_name): continue - uri = "{}://".format(store_name) + uri = f"{store_name}://" if fname.startswith(uri): return True return False @@ -340,7 +340,7 @@ class IrAttachment(models.Model): ( normalize_domain( [ - ("store_fname", "=like", "{}://%".format(storage)), + ("store_fname", "=like", f"{storage}://%"), # for res_field, see comment in # _force_storage_to_object_storage "|", @@ -360,7 +360,7 @@ class IrAttachment(models.Model): total = len(attachment_ids) start_time = time.time() _logger.info( - "Moving %d attachments from %s to" " DB for fast access", total, storage + "Moving %d attachments from %s to DB for fast access", total, storage ) current = 0 for attachment_id in attachment_ids: @@ -399,7 +399,7 @@ class IrAttachment(models.Model): domain = [ "!", - ("store_fname", "=like", "{}://%".format(storage)), + ("store_fname", "=like", f"{storage}://%"), "|", ("res_field", "=", False), ("res_field", "!=", False), diff --git a/base_attachment_object_storage/models/strtobool.py b/base_attachment_object_storage/models/strtobool.py index 12f4b82..1a7ad55 100644 --- a/base_attachment_object_storage/models/strtobool.py +++ b/base_attachment_object_storage/models/strtobool.py @@ -18,4 +18,4 @@ def strtobool(value): try: return _MAP[str(value).lower()] except KeyError as error: - raise ValueError('"{}" is not a valid bool value'.format(value)) from error + raise ValueError(f'"{value}" is not a valid bool value') from error diff --git a/cloud_platform/models/cloud_platform.py b/cloud_platform/models/cloud_platform.py index f1cbfe5..e9b75c3 100644 --- a/cloud_platform/models/cloud_platform.py +++ b/cloud_platform/models/cloud_platform.py @@ -69,7 +69,7 @@ class CloudPlatform(models.AbstractModel): self.check() if configs.filestore.location == "remote": self.env["ir.attachment"].sudo().force_storage() - _logger.info("cloud platform configured for {}".format(platform_kind)) + _logger.info(f"cloud platform configured for {platform_kind}") @api.model def install(self): @@ -125,5 +125,5 @@ class CloudPlatform(models.AbstractModel): self._check_redis(environment_name) def _register_hook(self): - super(CloudPlatform, self)._register_hook() + super()._register_hook() self.sudo().check() diff --git a/cloud_platform/models/strtobool.py b/cloud_platform/models/strtobool.py index 12f4b82..1a7ad55 100644 --- a/cloud_platform/models/strtobool.py +++ b/cloud_platform/models/strtobool.py @@ -18,4 +18,4 @@ def strtobool(value): try: return _MAP[str(value).lower()] except KeyError as error: - raise ValueError('"{}" is not a valid bool value'.format(value)) from error + raise ValueError(f'"{value}" is not a valid bool value') from error diff --git a/cloud_platform_azure/README.md b/cloud_platform_azure/README.rst similarity index 68% rename from cloud_platform_azure/README.md rename to cloud_platform_azure/README.rst index 449ab29..1f7bd5d 100644 --- a/cloud_platform_azure/README.md +++ b/cloud_platform_azure/README.rst @@ -1,4 +1,5 @@ -# Cloud Platform Azure +Cloud Platform Azure +==================== Install addons specific to the Azure setup. diff --git a/cloud_platform_azure/models/cloud_platform.py b/cloud_platform_azure/models/cloud_platform.py index b72d229..9f6a7e7 100644 --- a/cloud_platform_azure/models/cloud_platform.py +++ b/cloud_platform_azure/models/cloud_platform.py @@ -5,7 +5,6 @@ import os import re from odoo import api, models - from odoo.addons.cloud_platform.models.cloud_platform import ( FilestoreKind, PlatformConfig, @@ -19,13 +18,13 @@ class CloudPlatform(models.AbstractModel): @api.model def _filestore_kinds(self): - kinds = super(CloudPlatform, self)._filestore_kinds() + kinds = super()._filestore_kinds() kinds["azure"] = AZURE_STORE_KIND return kinds @api.model def _platform_kinds(self): - kinds = super(CloudPlatform, self)._platform_kinds() + kinds = super()._platform_kinds() kinds.append("azure") return kinds diff --git a/kwkhtmltopdf_assets/models/ir_qweb.py b/kwkhtmltopdf_assets/models/ir_qweb.py index 9025b96..702c4d4 100644 --- a/kwkhtmltopdf_assets/models/ir_qweb.py +++ b/kwkhtmltopdf_assets/models/ir_qweb.py @@ -6,7 +6,6 @@ from odoo.tools import config class IrQweb(models.AbstractModel): - _inherit = "ir.qweb" def _generate_asset_nodes_cache( diff --git a/logging_json/json_log.py b/logging_json/json_log.py index 8c5821c..2b7c5f7 100644 --- a/logging_json/json_log.py +++ b/logging_json/json_log.py @@ -35,7 +35,7 @@ class OdooJsonFormatter(jsonlogger.JsonFormatter): record.dbname = getattr(threading.current_thread(), "dbname", "?") record.request_id = getattr(threading.current_thread(), "request_uuid", None) record.uid = getattr(threading.current_thread(), "uid", None) - _super = super(OdooJsonFormatter, self) + _super = super() return _super.add_fields(log_record, record, message_dict) diff --git a/logging_json/strtobool.py b/logging_json/strtobool.py index 12f4b82..1a7ad55 100644 --- a/logging_json/strtobool.py +++ b/logging_json/strtobool.py @@ -18,4 +18,4 @@ def strtobool(value): try: return _MAP[str(value).lower()] except KeyError as error: - raise ValueError('"{}" is not a valid bool value'.format(value)) from error + raise ValueError(f'"{value}" is not a valid bool value') from error diff --git a/monitoring_status/controllers/main.py b/monitoring_status/controllers/main.py index 21b6893..1ea77c3 100644 --- a/monitoring_status/controllers/main.py +++ b/monitoring_status/controllers/main.py @@ -7,7 +7,6 @@ import logging import werkzeug from odoo import http - from odoo.addons.web.controllers.main import ensure_db diff --git a/session_redis/http.py b/session_redis/http.py index 6459529..93145f0 100644 --- a/session_redis/http.py +++ b/session_redis/http.py @@ -72,15 +72,14 @@ def purge_fs_sessions(path): if is_true(os.environ.get("ODOO_SESSION_REDIS")): if sentinel_host: _logger.debug( - "HTTP sessions stored in Redis with prefix '%s'. " - "Using Sentinel on %s:%s", + "HTTP sessions stored in Redis with prefix '%s'. Using Sentinel on %s:%s", prefix or "", sentinel_host, sentinel_port, ) else: _logger.debug( - "HTTP sessions stored in Redis with prefix '%s' on " "%s:%s", + "HTTP sessions stored in Redis with prefix '%s' on %s:%s", prefix or "", host, port, diff --git a/session_redis/session.py b/session_redis/session.py index d327474..8064976 100644 --- a/session_redis/session.py +++ b/session_redis/session.py @@ -60,7 +60,7 @@ class RedisSessionStore(SessionStore): else: user_msg = "anonymous user" _logger.debug( - "saving session with key '%s' and " "expiration of %s seconds for %s", + "saving session with key '%s' and expiration of %s seconds for %s", key, expiration, user_msg, @@ -80,7 +80,7 @@ class RedisSessionStore(SessionStore): def get(self, sid): if not self.is_valid_key(sid): _logger.debug( - "session with invalid sid '%s' has been asked, " "returning a new one", + "session with invalid sid '%s' has been asked, returning a new one", sid, ) return self.new() diff --git a/session_redis/strtobool.py b/session_redis/strtobool.py index 12f4b82..1a7ad55 100644 --- a/session_redis/strtobool.py +++ b/session_redis/strtobool.py @@ -18,4 +18,4 @@ def strtobool(value): try: return _MAP[str(value).lower()] except KeyError as error: - raise ValueError('"{}" is not a valid bool value'.format(value)) from error + raise ValueError(f'"{value}" is not a valid bool value') from error