Skip to content
Open
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
25 changes: 8 additions & 17 deletions ci/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import os
import subprocess
import sys
from os.path import abspath
from os.path import dirname
from os.path import exists
from os.path import join
from os.path import relpath
from os.path import abspath, dirname, exists, join, relpath

base_path = dirname(dirname(abspath(__file__)))
templates_path = join(base_path, "ci", "templates")
Expand All @@ -31,7 +22,7 @@ def exec_in_env():
if not exists(env_path):
import subprocess

print("Making bootstrap env in: {0} ...".format(env_path))
print(f"Making bootstrap env in: {env_path} ...")
try:
check_call([sys.executable, "-m", "venv", env_path])
except subprocess.CalledProcessError:
Expand All @@ -43,9 +34,9 @@ def exec_in_env():
check_call([join(bin_path, "pip"), "install", "jinja2", "tox", "matrix"])
python_executable = join(bin_path, "python")
if not os.path.exists(python_executable):
python_executable += '.exe'
python_executable += ".exe"

print("Re-executing with: {0}".format(python_executable))
print(f"Re-executing with: {python_executable}")
print("+ exec", python_executable, __file__, "--no-env")
os.execv(python_executable, [python_executable, __file__, "--no-env"])

Expand All @@ -54,7 +45,7 @@ def main():
import jinja2
import matrix

print("Project path: {0}".format(base_path))
print(f"Project path: {base_path}")

jinja = jinja2.Environment(
loader=jinja2.FileSystemLoader(templates_path),
Expand All @@ -64,7 +55,7 @@ def main():
)

tox_environments = {}
for (alias, conf) in matrix.from_file(join(base_path, "setup.cfg")).items():
for alias, conf in matrix.from_file(join(base_path, "setup.cfg")).items():
deps = conf["dependencies"]
tox_environments[alias] = {
"deps": deps.split(),
Expand All @@ -81,7 +72,7 @@ def main():
relative = relpath(root, templates_path)
with open(join(base_path, relative, name), "w") as fh:
fh.write(jinja.get_template(join(relative, name)).render(tox_environments=tox_environments))
print("Wrote {}".format(name))
print(f"Wrote {name}")
print("DONE.")


Expand All @@ -92,5 +83,5 @@ def main():
elif not args:
exec_in_env()
else:
print("Unexpected arguments {0}".format(args), file=sys.stderr)
print(f"Unexpected arguments {args}", file=sys.stderr)
sys.exit(1)
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
project = "pre-commit-vauxoo"
year = "2022"
author = "Vauxoo"
copyright = "{}, {}".format(year, author)
copyright = f"{year}, {author}"
version = release = "8.2.31"

pygments_style = "trac"
Expand Down
16 changes: 16 additions & 0 deletions src/pre_commit_vauxoo/cfg/.pre-commit-config-autofix.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ repos:
- --config=.oca_hooks-autofix.cfg
- --fix
{%- endif %}
{%- if ruff_matrix_value >= 20 %}
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.16
hooks:
- id: ruff
name: ruff (check + fix)
args: [--fix, --unsafe-fixes]
{%- if ruff_matrix_value >= 30 %}
- id: ruff-format
name: ruff (format)
{%- endif %}
{%- endif %}
{%- if ruff_matrix_value < 30 %}
- repo: https://github.com/psf/black-pre-commit-mirror.git
{%- if black_autoflake_matrix_value >= 20 %}
rev: 25.12.0
Expand All @@ -83,6 +96,7 @@ repos:
- --remove-all-unused-imports
- --remove-duplicate-keys
- --remove-unused-variables
{%- endif %}
- repo: local
hooks:
- id: prettier
Expand Down Expand Up @@ -123,6 +137,7 @@ repos:
{%- if pre_commit_matrix_value >= 20 %}
- id: requirements-txt-fixer
{%- endif %}
{%- if ruff_matrix_value < 30 %}
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
Expand All @@ -132,6 +147,7 @@ repos:
rev: 7.0.0
hooks:
- id: isort
{%- endif %}
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.6
hooks:
Expand Down
10 changes: 10 additions & 0 deletions src/pre_commit_vauxoo/cfg/.pre-commit-config-optional.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ repos:
language: python
pass_filenames: false
always_run: true
{%- if ruff_matrix_value >= 20 %}
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.16
hooks:
- id: ruff
name: ruff optional rules (SIM/RUF/C90)
args: [--extend-select, "SIM,RUF,C90", --exit-non-zero-on-fix]
{%- endif %}
{%- if ruff_matrix_value < 30 %}
- repo: https://github.com/PyCQA/flake8
{%- if flake8_matrix_value >= 20 %}
rev: 7.3.0
Expand All @@ -84,6 +93,7 @@ repos:
{%- endif %}
args:
- --config=.flake8-optional
{%- endif %}
- repo: https://github.com/PyCQA/bandit
rev: 1.9.2
hooks:
Expand Down
10 changes: 10 additions & 0 deletions src/pre_commit_vauxoo/cfg/.pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ default_language_version:
python: python3
node: "24.13.0"
repos:
{%- if ruff_matrix_value >= 20 %}
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.16
hooks:
- id: ruff
name: ruff mandatory checks
args: [--fix, --exit-non-zero-on-fix]
{%- endif %}
{%- if ruff_matrix_value < 30 %}
- repo: https://github.com/PyCQA/flake8
{%- if flake8_matrix_value >= 20 %}
rev: 7.3.0
Expand All @@ -40,6 +49,7 @@ repos:
hooks:
- id: flake8
name: flake8 mandatory checks
{%- endif %}
- repo: https://github.com/OCA/pylint-odoo
{%- if pylint_matrix_value >= 20 %}
rev: v10.0.2
Expand Down
59 changes: 59 additions & 0 deletions src/pre_commit_vauxoo/cfg/ruff.toml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# ruff.toml — generated by pre-commit-vauxoo
# Replaces: .flake8, .isort.cfg, pyproject.toml [tool.black] when ruff is active.
# Reference: https://docs.astral.sh/ruff/configuration/

line-length = 119
target-version = "py310"

[lint]
select = [
"E", # pycodestyle errors (replaces flake8 core E)
"W", # pycodestyle warnings (replaces flake8 core W)
"F", # pyflakes (replaces flake8 core F)
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"I", # isort
"UP", # pyupgrade
"N", # pep8-naming
]

# Carried forward from cfg/.flake8 + Odoo-specific additions.
# E133: not in ruff (pep8 extension rule) — omitted safely.
# F601: not in ruff — omitted safely.
# W503/W504: removed from PEP8 modern — omitted safely.
ignore = [
"B006", # mutable-argument-default — Odoo uses lists in field defaults
"B008", # function-call-in-default-argument — Odoo uses callables in field defaults
"B024", # abstract-base-class-without-abstract-method
# B036: not implemented in ruff (flake8-bugbear only)
# E123: not implemented in ruff — omitted safely
"E203", # whitespace-before-punctuation (ruff-format compat)
"E226", # missing-whitespace-around-arithmetic-operator
"E241", # multiple-spaces-after-comma (preview rule, ignored for compat)
"E242", # tab-after-comma (preview rule, ignored for compat)
"E501", # line-too-long (delegated to ruff format)
"E741", # ambiguous-variable-name
"F811", # redefinition-of-unused-name
"UP031", # printf-string-formatting (--keep-percent-format compat)
]

[lint.per-file-ignores]
"__init__.py" = ["F401"] # unused-import OK in Odoo __init__.py (re-exports)
"__manifest__.py" = ["B018"] # bare dict literal is the Odoo manifest format

[lint.isort]
# NOTE: isort behavioral delta from legacy .isort.cfg
# Legacy .isort.cfg used 7 sections: FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER
# Ruff supports only standard sections; odoo and odoo.addons are merged into first-party.
# Cosmetic difference only — no CI failures.
known-first-party = ["odoo", "odoo.addons"]
default-section = "third-party"
combine-as-imports = true
split-on-trailing-comma = true
force-sort-within-sections = false

[format]
line-ending = "auto"
quote-style = {{ '"preserve"' if skip_string_normalization else '"double"' }}
indent-style = "space"
skip-magic-trailing-comma = false
3 changes: 3 additions & 0 deletions src/pre_commit_vauxoo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ def precommit_hooks_type_callback(ctx, param, value):
🟢 5. pre-commit framework
🟢 6. Pylint/pylint-odoo
🟢 7. flake8
🟢 8. Ruff (linter + formatter)
(0-10 → disabled; 20 → ruff check+format replaces flake8+black+isort+autoflake+pyupgrade in parallel;
30 → legacy tools removed from generated configs)

⚠️ Higher values or empty valuesmay introduce formatting changes, stricter linting,
or non-backward-compatible fixes (especially for XML, Python, and JS files).""",
Expand Down
3 changes: 2 additions & 1 deletion src/pre_commit_vauxoo/pre_commit_vauxoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"pre_commit_matrix_value",
"pylint_matrix_value",
"flake8_matrix_value",
"ruff_matrix_value",
)
DEFAULT_MAX_COMPATIBILITY = 1000000

Expand Down Expand Up @@ -439,7 +440,7 @@ def print_summary(all_status):
if test_result["status"]
else logging_colored.colorized_msg(test_result["status_msg"], test_result["level"])
)
summary_msg.append("| {:<28}{}".format(test_name, outcome))
summary_msg.append(f"| {test_name:<28}{outcome}")
summary_msg.append("+" + "=" * 39)
_logger.info("Tests summary\n%s", "\n".join(summary_msg))

Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pytest<8.3.5 ; python_version >= '3.13' # Latest pytest==8.3.5 and py3.13 raise
pytest-cov
pytest-xdist
pyyaml
ruff
setuptools >=42
tox
twine
Expand Down
Loading
Loading