-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Pre-commit compatibility for odoo < 13
- Loading branch information
1 parent
f3df4ad
commit 98fdf50
Showing
7 changed files
with
372 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 175 additions & 0 deletions
175
{% if odoo_version < 13 %}.pre-commit-config.yaml.jinja{% endif %}.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
{# We cannot use the same pre-commit config as MQT's because paths don't match | ||
and it's designed only for Odoo 13.0+, so we design our own version, which | ||
should be as close as possible to MQT's -#} | ||
|
||
{#- This namespace holds repo versions #} | ||
{%- set proj_rev = namespace() %} | ||
{%- set proj_rev.pre_commit_hooks = "v3.2.0" %} | ||
{%- set proj_rev.odoo_pre_commit_hooks = "v0.0.29" %} | ||
{%- set proj_rev.node_version = "14.14.0" %} | ||
{%- set proj_rev.mirrors_prettier = "v2.1.2" %} | ||
{%- set proj_rev.mirrors_prettier_prettier = "prettier@2.1.2" %} | ||
{%- set proj_rev.mirrors_prettier_xml = "@prettier/plugin-xml@0.12.0" %} | ||
{%- set proj_rev.mirrors_eslint = "v7.8.1" %} | ||
{%- set proj_rev.pylint_odoo = "v8.0.0" -%} | ||
exclude: | | ||
(?x) | ||
# NOT INSTALLABLE ADDONS | ||
# END NOT INSTALLABLE ADDONS | ||
# Files and folders generated by bots, to avoid loops | ||
/static/description/index\.html$| | ||
# Files that fail if changed manually | ||
.*\.(diff|patch)$| | ||
# Library files can have extraneous formatting (even minimized) | ||
/static/(src/)?lib/| | ||
# You don't usually want a bot to modify your legal texts | ||
(LICENSE.*|COPYING.*) | ||
default_language_version: | ||
python: python3 | ||
node: "{{ proj_rev.node_version }}" | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: forbidden-files | ||
name: forbidden files | ||
entry: found forbidden files; remove them | ||
language: fail | ||
files: "\\.rej$" | ||
- repo: https://github.com/oca/maintainer-tools | ||
rev: b9c963d | ||
hooks: | ||
# update the NOT INSTALLABLE ADDONS section above | ||
- id: oca-update-pre-commit-excluded-addons | ||
args: | ||
- --addons-dir | ||
- odoo/custom/src/private | ||
- repo: https://github.com/myint/autoflake | ||
rev: v1.4 | ||
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: 20.8b1 | ||
hooks: | ||
- id: black | ||
additional_dependencies: ["click<8.1.0"] | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v2.7.2 | ||
hooks: | ||
- id: pyupgrade | ||
args: | ||
- --keep-percent-format | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.11.5 | ||
hooks: | ||
- id: isort | ||
name: isort except __init__.py | ||
args: [--settings, .] | ||
exclude: /__init__\.py$ | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 3.8.3 | ||
hooks: | ||
- id: flake8 | ||
name: flake8 except __init__.py | ||
exclude: /__init__\.py$ | ||
additional_dependencies: ["flake8-bugbear==20.1.4", "importlib-metadata<5.0.0"] | ||
- id: flake8 | ||
name: flake8 only __init__.py | ||
args: ["--extend-ignore=F401"] # ignore unused imports in __init__.py | ||
files: /__init__\.py$ | ||
additional_dependencies: ["flake8-bugbear==20.1.4", "importlib-metadata<5.0.0"] | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
# HACK https://github.com/prettier/prettier/issues/15696 | ||
rev: {{ proj_rev.mirrors_prettier }} | ||
hooks: | ||
- id: prettier | ||
name: prettier + plugin-xml | ||
additional_dependencies: | ||
# HACK https://github.com/prettier/pre-commit/issues/16#issuecomment-713474520 | ||
- {{ proj_rev.mirrors_prettier_prettier }} | ||
- "{{ proj_rev.mirrors_prettier_xml }}" | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: {{ proj_rev.pre_commit_hooks }} | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
{%- if odoo_version >= 11 %} | ||
- id: debug-statements | ||
{%- endif %} | ||
- id: fix-encoding-pragma | ||
{%- if odoo_version >= 11 %} | ||
args: ["--remove"] | ||
{%- endif %} | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: check-executables-have-shebangs | ||
- id: check-merge-conflict | ||
{%- if odoo_version >= 11 %} | ||
args: [--assume-in-merge] | ||
exclude: \.rst$ # HACK https://github.com/pre-commit/pre-commit-hooks/issues/985 | ||
{%- endif %} | ||
- id: check-symlinks | ||
- id: check-xml | ||
- id: mixed-line-ending | ||
args: ["--fix=lf"] | ||
{%- if odoo_version >= 11 %} | ||
- repo: https://github.com/OCA/pylint-odoo | ||
rev: {{ proj_rev.pylint_odoo }} | ||
hooks: | ||
- id: pylint_odoo | ||
name: pylint with optional checks | ||
args: | ||
- --rcfile=.pylintrc | ||
- --exit-zero | ||
verbose: true | ||
- id: pylint_odoo | ||
args: | ||
- --rcfile=.pylintrc-mandatory | ||
{%- else %} | ||
- repo: https://github.com/pycqa/pylint | ||
rev: v2.11.1 | ||
hooks: | ||
- id: pylint | ||
name: pylint with optional checks | ||
args: | ||
- --valid_odoo_versions=10.0 | ||
- --rcfile=.pylintrc | ||
- --exit-zero | ||
verbose: true | ||
additional_dependencies: | ||
- isort==4.3.21 | ||
- pylint-odoo==5.0.5 | ||
- id: pylint | ||
name: pylint with mandatory checks | ||
args: | ||
- --valid_odoo_versions=10.0 | ||
- --rcfile=.pylintrc-mandatory | ||
additional_dependencies: | ||
- isort==4.3.21 | ||
- pylint-odoo==5.0.5 | ||
{%- endif %} | ||
- repo: https://github.com/pre-commit/mirrors-eslint | ||
rev: {{ proj_rev.mirrors_eslint }} | ||
hooks: | ||
- id: eslint | ||
verbose: true | ||
args: | ||
- --color | ||
- --fix | ||
- repo: https://github.com/oca/maintainer-tools | ||
rev: 05e2174 | ||
hooks: | ||
- id: oca-gen-addon-readme | ||
args: | ||
- --addons-dir=odoo/custom/src/private | ||
- --org-name={{ project_author }} | ||
- --repo-name={{ project_name }} | ||
- --gen-html | ||
- --branch={{ odoo_version }} | ||
- --template-filename=.module-readme.rst.j2 |
Oops, something went wrong.