Skip to Content

run_lint_addon.sh — Ruff import/format runner with pylint‑odoo

Path: /srv/pmiverse/_pmiconfig/scripts/test/run_lint_addon.sh

Purpose - Apply PMIverse lint and formatting rules to an addon or all addons in a repository. - Enforce Ruff import sorting followed by Ruff formatting with the canonical Odoo-derived Python policy, and run pylint-odoo when available.

Usage

# Lint a single addon
/srv/pmiverse/_pmiconfig/scripts/test/run_lint_addon.sh --addon <addon_dir>

# Lint all addons in a repository
/srv/pmiverse/_pmiconfig/scripts/test/run_lint_addon.sh --repo <repo_root>

# Check-only mode (no Ruff writes)
/srv/pmiverse/_pmiconfig/scripts/test/run_lint_addon.sh --repo <repo_root> --check

Options - --addon <path>: Path to an addon (must contain __manifest__.py). - --repo <path>: Path to a repo; the script will discover addons by __manifest__.py. - --check: Do not modify files; check Ruff imports and formatting. - -h, --help: Show help.

Behavior - Activates instance venv: /srv/pmiverse/_pmisuite18/venv. - Runs ruff check --select I before ruff format, always with the canonical shared configuration. - Excludes _to_migrate/ and generated packaging through the canonical configuration. - Runs pylint with --load-plugins=pylint_odoo if pylint is installed in the venv. - Safe and idempotent; exits non-zero on argument or formatting failures (pylint messages do not fail the script by design).

Notes - The shared Ruff configuration targets the selected Odoo checkout's minimum Python version. - Use pre-commit for automatic enforcement on commit in addon repositories. - For repo‑wide refactors, prefer --check first to review proposed changes.