Skip to content

Commit 94c0314

Browse files
committed
[chore] pre-commit autoupdate
Also fix new ruff violations closes #102 Related: odoo/upgrade#6192 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent d116bc4 commit 94c0314

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

.pre-commit-config.yaml

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

1414
- repo: https://github.com/astral-sh/ruff-pre-commit
15-
rev: v0.3.0
15+
rev: v0.5.0
1616
hooks:
1717
- id: ruff
1818
name: Check code with Ruff, apply automatic fixes
1919
args: [ --exit-non-zero-on-fix ]
2020
- id: ruff-format
2121
name: Format code with Ruff
2222
- repo: https://github.com/pre-commit/pre-commit-hooks
23-
rev: v4.5.0
23+
rev: v4.6.0
2424
hooks:
2525
- id: check-xml
2626
- id: check-yaml

src/base/17.0.1.3/attr_domains2expr.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ def find_target(elem):
187187
def is_simple_pred(expr):
188188
if expr in ("0", "1", "True", "False"):
189189
return True
190-
if re.match(r"""context\.get\((['"])\w+\1\)""", expr):
191-
return True
192-
return False
190+
return bool(re.match(r"""context\.get\((['"])\w+\1\)""", expr))
193191

194192

195193
def fix_elem(cr, model, elem, comb_arch):
@@ -455,7 +453,7 @@ def convert_attrs_val(cr, model, field_path, val):
455453
)
456454
if isinstance(val, ast.BoolOp):
457455
return "({})".format(
458-
(" and " if type(val.op) == ast.And else " or ").join(
456+
(" and " if type(val.op) is ast.And else " or ").join(
459457
convert_attrs_val(cr, model, field_path, v) for v in val.values
460458
)
461459
)

src/util/domains.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def adapter(leaf, in_or, negated):
368368
""".format(df=df),
369369
[match_old],
370370
)
371-
for id_, model, domain in cr.fetchall():
371+
for id_, model, domain in cr.fetchall(): # noqa: PLR1704
372372
new_domain = _adapt_one_domain(
373373
cr, target_model, old, new, model, domain, adapter=adapter, force_adapt=force_adapt
374374
)

src/util/fields.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,11 +1211,11 @@ def adapt_depends(cr, model, old, new, skip_inherit=()):
12111211
""",
12121212
[match_old],
12131213
)
1214-
for id_, model, depends in cr.fetchall():
1214+
for id_, field_model, depends in cr.fetchall():
12151215
temp_depends = depends.split(",")
12161216
for i in range(len(temp_depends)):
12171217
domain = _adapt_one_domain(
1218-
cr, target_model, old, new, model, [(temp_depends[i], "=", "depends")], force_adapt=True
1218+
cr, target_model, old, new, field_model, [(temp_depends[i], "=", "depends")], force_adapt=True
12191219
)
12201220
if domain:
12211221
temp_depends[i] = domain[0][0]
@@ -1246,8 +1246,10 @@ def adapt_related(cr, model, old, new, skip_inherit=()):
12461246
""",
12471247
[match_old],
12481248
)
1249-
for id_, model, related in cr.fetchall():
1250-
domain = _adapt_one_domain(cr, target_model, old, new, model, [(related, "=", "related")], force_adapt=True)
1249+
for id_, field_model, related in cr.fetchall():
1250+
domain = _adapt_one_domain(
1251+
cr, target_model, old, new, field_model, [(related, "=", "related")], force_adapt=True
1252+
)
12511253
if domain:
12521254
cr.execute("UPDATE ir_model_fields SET related = %s WHERE id = %s", [domain[0][0], id_])
12531255

src/util/pg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def _parallel_execute_threaded(cr, queries, logger=_logger):
9696
cursor = db_connect(cr.dbname).cursor
9797

9898
def execute(query):
99-
with cursor() as cr:
100-
cr.execute(query)
101-
cnt = cr.rowcount
102-
cr.commit()
99+
with cursor() as tcr:
100+
tcr.execute(query)
101+
cnt = tcr.rowcount
102+
tcr.commit()
103103
return cnt
104104

105105
cr.commit()

src/util/records.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,9 +1147,9 @@ def delete_unused(cr, *xmlids, **kwargs):
11471147
)
11481148

11491149
deleted = []
1150-
for model, ids, xmlids in cr.fetchall():
1150+
for model, ids, xids in cr.fetchall():
11511151
table = table_of_model(cr, model)
1152-
res_id_to_xmlid = dict(zip(ids, xmlids))
1152+
res_id_to_xmlid = dict(zip(ids, xids))
11531153

11541154
sub = " UNION ".join(
11551155
[

0 commit comments

Comments
 (0)