Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: pre-commit run --all-files --show-diff-on-failure --color=always
- name: Check that all files generated by pre-commit are in git
run: |
newfiles="$(git ls-files --others --exclude-from=.gitignore)"
newfiles="$(git ls-files --others --exclude-from=.gitignore --exclude=.ruff_cache)"
if [ "$newfiles" != "" ] ; then
echo "Please check-in the following files:"
echo "$newfiles"
Expand Down
181 changes: 66 additions & 115 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,119 +21,70 @@ exclude: |
^docs/_templates/.*\.html$|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
python: python3
node: "16.17.0"

repos:
- repo: local
hooks:
# These files are most likely copier diff rejection junks; if found,
# review them manually, fix the problem (if needed) and remove them
- id: forbidden-files
name: forbidden files
entry: found forbidden files; remove them
language: fail
files: "\\.rej$"
- id: en-po-files
name: en.po files cannot exist
entry: found a en.po file
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: 4cd2b852214dead80822e93e6749b16f2785b2fe
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
args: ["https://github.com/camptocamp/odoo-cloud-platform"]
- repo: https://github.com/myint/autoflake
rev: v1.6.1
hooks:
- id: autoflake
args:
- --expand-star-imports
- --ignore-init-module-imports
- --in-place
- --remove-all-unused-imports
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
name: prettier (with plugin-xml)
additional_dependencies:
- "prettier@2.7.1"
- "@prettier/plugin-xml@2.2.0"
args:
- --plugin=@prettier/plugin-xml
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.24.0
hooks:
- id: eslint
verbose: true
args:
- --color
- --fix
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
- id: end-of-file-fixer
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
- id: debug-statements
- id: fix-encoding-pragma
args: ["--remove"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
# exclude files where underlines are not distinguishable from merge conflicts
exclude: /README\.rst$|^docs/.*\.rst$
- id: check-symlinks
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.38.2
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: isort except __init__.py
args:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.1.8
hooks:
- id: setuptools-odoo-make-default
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==21.9.2"]
- repo: https://github.com/OCA/pylint-odoo
rev: v8.0.19
hooks:
- id: pylint_odoo
name: pylint with optional checks
args:
- --rcfile=.pylintrc
- --exit-zero
verbose: true
- id: pylint_odoo
args:
- --rcfile=.pylintrc-mandatory

# pylint
- repo: https://github.com/pycqa/pylint
rev: v4.0.5
hooks:
- id: pylint
name: pylint odoo
# check only specific Odoo addons
files: odoo/local-src/
types: ['file', 'python'] # to not check .csv and .conf files
args: ["--rcfile=.ci/pylintrc_odoo"]
additional_dependencies: [pylint-odoo==v10.0.1]

# pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
- id: check-symlinks
- id: check-xml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
types_or: [python, javascript, css, xml, yaml]
- id: trailing-whitespace
types_or: [python, javascript, css, xml, yaml]

# Odoo pre-commit hooks
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.2.20
hooks:
- id: oca-checks-odoo-module
args:
- --disable=
xml-deprecated-tree-attribute,
xml-header-wrong,
xml-id-position-first,
- id: oca-checks-po
args: ["--fix"]

# ruff (= flake8 + isort + pyupgrade)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.4
hooks:
- id: ruff-check
args: [--fix, --show-fixes]
exclude: __manifest__.py|__init__.py
- id: ruff-format
args: [--diff]
exclude: __manifest__.py|__init__.py
- id: ruff-format
exclude: __manifest__.py|__init__.py

# rstcheck
- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.5
hooks:
- id: rstcheck

# setuptools-odoo
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.3.2
hooks:
- id: setuptools-odoo-make-default
8 changes: 4 additions & 4 deletions attachment_azure/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -162,7 +162,7 @@ def _store_file_read(self, fname, bin_size=False):
_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):
Expand All @@ -189,7 +189,7 @@ def _store_file_write(self, key, bin_data):
_("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

Expand All @@ -215,4 +215,4 @@ def _store_file_delete(self, fname):
# user
_logger.exception("Error during deletion of the file %s" % fname)
else:
super(IrAttachment, self)._store_file_delete(fname)
super()._store_file_delete(fname)
14 changes: 7 additions & 7 deletions base_attachment_object_storage/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -124,7 +124,7 @@ def _store_in_db_instead_of_object_storage_domain(self):
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])
Expand Down Expand Up @@ -236,7 +236,7 @@ def _file_delete(self, fname):
# 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:
Expand All @@ -249,7 +249,7 @@ def _is_file_from_a_store(self, fname):
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
Expand Down Expand Up @@ -340,7 +340,7 @@ def force_storage_to_db_for_special_fields(self, new_cr=False):
(
normalize_domain(
[
("store_fname", "=like", "{}://%".format(storage)),
("store_fname", "=like", f"{storage}://%"),
# for res_field, see comment in
# _force_storage_to_object_storage
"|",
Expand All @@ -360,7 +360,7 @@ def force_storage_to_db_for_special_fields(self, new_cr=False):
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:
Expand Down Expand Up @@ -399,7 +399,7 @@ def _force_storage_to_object_storage(self, new_cr=False):

domain = [
"!",
("store_fname", "=like", "{}://%".format(storage)),
("store_fname", "=like", f"{storage}://%"),
"|",
("res_field", "=", False),
("res_field", "!=", False),
Expand Down
2 changes: 1 addition & 1 deletion base_attachment_object_storage/models/strtobool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 2 additions & 8 deletions cloud_platform/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
{
"name": "Cloud Platform",
"summary": "Addons required for the Camptocamp Cloud Platform",
"version": "16.0.2.0.0",
"version": "16.0.2.0.1",
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Extra Tools",
"depends": [
"session_redis",
"monitoring_status",
"logging_json",
"server_environment", # OCA/server-tools
],
"depends": ["session_redis", "monitoring_status", "logging_json"],
"website": "https://github.com/camptocamp/odoo-cloud-platform",
"data": [],
"installable": True,
}
7 changes: 3 additions & 4 deletions cloud_platform/models/cloud_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from collections import namedtuple

from odoo import api, models
from odoo.tools.config import config

from .strtobool import strtobool

Expand Down Expand Up @@ -52,7 +51,7 @@ def _config_by_server_env(self, platform_kind, environment):
return configs.get(environment) or self._default_config()

def _get_running_env(self):
environment_name = config["running_env"]
environment_name = os.environ.get("RUNNING_ENV")
if environment_name.startswith("labs"):
# We allow to have environments such as 'labs-logistics'
# or 'labs-finance', in order to have the matching ribbon.
Expand All @@ -70,7 +69,7 @@ def _install(self, platform_kind):
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):
Expand Down Expand Up @@ -126,5 +125,5 @@ def check(self):
self._check_redis(environment_name)

def _register_hook(self):
super(CloudPlatform, self)._register_hook()
super()._register_hook()
self.sudo().check()
2 changes: 1 addition & 1 deletion cloud_platform/models/strtobool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Cloud Platform Azure
Cloud Platform Azure
====================

Install addons specific to the Azure setup.

Expand Down
5 changes: 2 additions & 3 deletions cloud_platform_azure/models/cloud_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re

from odoo import api, models

from odoo.addons.cloud_platform.models.cloud_platform import (
FilestoreKind,
PlatformConfig,
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion kwkhtmltopdf_assets/models/ir_qweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class IrQweb(models.AbstractModel):

_inherit = "ir.qweb"

def _generate_asset_nodes_cache(
Expand Down
Loading
Loading