Skip to content

Commit daa5888

Browse files
committed
[chore] pre-commit autoupdate + lint
closes #286 Related: odoo/upgrade#7882 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 86409e5 commit daa5888

File tree

9 files changed

+20
-11
lines changed

9 files changed

+20
-11
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ repos:
1414
files: '^src/\w+/(tests|0\.0\.0)/.*\.py$'
1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.11.3
17+
rev: v0.12.0
1818
hooks:
1919
- id: ruff
2020
name: Check code with Ruff, apply automatic fixes
2121
args: [ --exit-non-zero-on-fix ]
2222
- id: ruff-format
2323
name: Format code with Ruff
2424
- repo: https://github.com/crate-ci/typos
25-
rev: v1.31.1
25+
rev: v1.33.1
2626
hooks:
2727
- id: typos
2828
- repo: https://github.com/pre-commit/pre-commit-hooks

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ convention = "pep257"
116116
# and for upgrade scripts
117117
"src/*/*/{pre,post,end}-*.py" = ["D"]
118118

119+
[tool.ruff.per-file-target-version]
120+
"tools/fetch-release-notes-video-id.py" = "py312"
119121

120122
[tool.typos.files]
121123
extend-exclude = [

src/base/0.0.0/end-no-respawn-fields.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ def migrate(cr, version):
2222
execute_values(
2323
cr._obj,
2424
"INSERT INTO no_respawn(model, field) VALUES %s",
25-
# fmt:off
2625
[
2726
(model, field)
2827
for model, fields in util.ENVIRON["__renamed_fields"].items()
2928
for field, new_name in fields.items()
3029
if new_name is None # means removed :p
3130
],
32-
# fmt:on
3331
)
3432
cr.execute(
3533
"""

src/util/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ def adapter(leaf, _or, _neg):
10781078

10791079

10801080
def is_field_anonymized(cr, model, field):
1081-
from .modules import module_installed
1081+
from .modules import module_installed # noqa: PLC0415
10821082

10831083
_validate_model(model)
10841084
if not module_installed(cr, "anonymization"):

src/util/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def _ir_values_value(cr, prefix=None):
155155
cache = getattr(_ir_values_value, "cache", None)
156156

157157
if cache is None:
158-
from .pg import column_type
158+
from .pg import column_type # noqa: PLC0415
159159

160160
if column_type(cr, "ir_values", "value") == "bytea":
161161
cr.execute("SELECT character_set_name FROM information_schema.character_sets")

src/util/orm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
# ruff: noqa: PLC0415
23
"""
34
Utility functions to perform operations via the ORM.
45

src/util/pg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def alter_column_type(cr, table, column, type, using=None, where=None, logger=_l
637637
logger.info("Column %r of table %r is already defined as %r", column, table, type)
638638
return
639639

640-
# remove the existing linked `ir_model_fields_selection` recods in case it was a selection field
640+
# remove the existing linked `ir_model_fields_selection` records in case it was a selection field
641641
if table_exists(cr, "ir_model_fields_selection"):
642642
cr.execute(
643643
"""
@@ -1008,6 +1008,9 @@ def __init__(self, list_=(), quoted=()):
10081008
self._trailing_comma = False
10091009
self._alias = None
10101010

1011+
def __hash__(self):
1012+
return hash((tuple(self._unquoted_columns), self._leading_comma, self._trailing_comma, self._alias))
1013+
10111014
def __eq__(self, other):
10121015
return (
10131016
isinstance(other, ColumnList)

src/util/records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ def __update_record_from_xml(
10771077
fields,
10781078
done_refs,
10791079
):
1080-
from .modules import get_manifest
1080+
from .modules import get_manifest # noqa: PLC0415
10811081

10821082
if "." not in xmlid:
10831083
raise ValueError("Please use fully qualified name <module>.<name>")

src/util/report.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
import lxml
99
from docutils.core import publish_string
1010

11+
try:
12+
import markdown
13+
except ImportError:
14+
markdown = None
15+
1116
from .helpers import _validate_model
1217
from .misc import parse_version
1318

@@ -189,7 +194,7 @@ def rst2html(rst):
189194

190195

191196
def md2html(md):
192-
import markdown
197+
assert markdown
193198

194199
mdversion = markdown.__version_info__ if hasattr(markdown, "__version_info__") else markdown.version_info
195200
extensions = [
@@ -259,9 +264,9 @@ def ref(xid):
259264

260265
except MigrationError:
261266
try:
262-
from openerp.modules.registry import RegistryManager
267+
from openerp.modules.registry import RegistryManager # noqa: PLC0415
263268
except ImportError:
264-
from openerp.modules.registry import Registry as RegistryManager
269+
from openerp.modules.registry import Registry as RegistryManager # noqa: PLC0415
265270
registry = RegistryManager.get(cr.dbname)
266271
user = registry["res.users"].browse(cr, SUPERUSER_ID, uid, context=ctx)
267272

0 commit comments

Comments
 (0)