diff --git a/.pylintrc-mandatory.jinja b/.pylintrc-mandatory.jinja index a9be278d..7fea6737 100644 --- a/.pylintrc-mandatory.jinja +++ b/.pylintrc-mandatory.jinja @@ -18,7 +18,51 @@ valid-odoo-versions={{ odoo_version }} [MESSAGES CONTROL] disable=all - +{% if odoo_version < 11 %} +enable=anomalous-backslash-in-string, + # api-one-deprecated, + api-one-multi-together, + assignment-from-none, + attribute-deprecated, + class-camelcase, + dangerous-default-value, + dangerous-view-replace-wo-priority, + duplicate-id-csv, + duplicate-key, + duplicate-xml-fields, + duplicate-xml-record-id, + eval-referenced, + eval-used, + incoherent-interpreter-exec-perm, + manifest-author-string, + manifest-deprecated-key, + manifest-required-key, + manifest-version-format, + method-compute, + method-inverse, + method-required-super, + method-search, + missing-import-error, + missing-manifest-dependency, + openerp-exception-warning, + pointless-statement, + pointless-string-statement, + print-used, + redundant-keyword-arg, + redundant-modulename-xml, + reimported, + relative-import, + return-in-init, + rst-syntax-error, + sql-injection, + too-few-format-args, + translation-field, + # translation-required, + unreachable, + use-vim-comment, + wrong-tabs-instead-of-spaces, + xml-syntax-error +{%- else %} enable=attribute-deprecated, manifest-author-string, manifest-deprecated-key, @@ -87,6 +131,7 @@ enable=attribute-deprecated, translation-too-many-args, translation-unsupported-format {%- endif %} +{%- endif %} [REPORTS] msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/.pylintrc.jinja b/.pylintrc.jinja index 496f645a..18343938 100644 --- a/.pylintrc.jinja +++ b/.pylintrc.jinja @@ -30,6 +30,70 @@ disable=all # config as a blocking check. # messages that do not cause the lint step to fail +{%- if odoo_version < 11%} +enable=anomalous-backslash-in-string, + # api-one-deprecated, + api-one-multi-together, + assignment-from-none, + attribute-deprecated, + class-camelcase, + dangerous-default-value, + dangerous-view-replace-wo-priority, + duplicate-id-csv, + duplicate-key, + duplicate-xml-fields, + duplicate-xml-record-id, + eval-referenced, + eval-used, + incoherent-interpreter-exec-perm, + license-allowed, + manifest-author-string, + manifest-deprecated-key, + {%- if project_author %} + manifest-required-author, + {%- endif %} + manifest-required-key, + manifest-version-format, + method-compute, + method-inverse, + method-required-super, + method-search, + missing-import-error, + missing-manifest-dependency, + openerp-exception-warning, + pointless-statement, + pointless-string-statement, + print-used, + redundant-keyword-arg, + redundant-modulename-xml, + reimported, + relative-import, + return-in-init, + rst-syntax-error, + sql-injection, + too-few-format-args, + translation-field, + # translation-required, + unreachable, + use-vim-comment, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + # messages that do not cause the lint step to fail + consider-merging-classes-inherited, + create-user-wo-reset-password, + dangerous-filter-wo-user, + deprecated-module, + file-not-used, + invalid-commit, + missing-newline-extrafiles, + missing-readme, + no-utf8-coding-comment, + odoo-addons-relative-import, + old-api7-method-defined, + redefined-builtin, + too-complex, + unnecessary-utf8-coding-comment +{%- else %} enable=attribute-deprecated, consider-merging-classes-inherited, invalid-commit, @@ -120,6 +184,7 @@ enable=attribute-deprecated, translation-unsupported-format, website-manifest-key-not-valid-uri {%- endif %} +{%- endif %} [REPORTS] msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} diff --git a/{% if odoo_version < 13 %}.pre-commit-config.yaml{% endif %}.jinja b/{% if odoo_version < 13 %}.pre-commit-config.yaml{% endif %}.jinja new file mode 100644 index 00000000..2f568bbb --- /dev/null +++ b/{% if odoo_version < 13 %}.pre-commit-config.yaml{% endif %}.jinja @@ -0,0 +1,176 @@ +{# 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 diff --git a/{% if odoo_version <= 12 %}.module-readme.rst.j2{% endif %}.jinja b/{% if odoo_version <= 12 %}.module-readme.rst.j2{% endif %}.jinja new file mode 100644 index 00000000..a506780d --- /dev/null +++ b/{% if odoo_version <= 12 %}.module-readme.rst.j2{% endif %}.jinja @@ -0,0 +1,84 @@ +{% raw -%} +{%- macro fragment(name, title, sub='=') %} +{%- if name in fragments %} +{{- title }} +{{ sub * title|length }} + +{{ fragments[name] }} +{% endif %} +{%- endmacro -%} + +{{ '=' * manifest.name|length }} +{{ manifest.name }} +{{ '=' * manifest.name|length }} + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge_devstat| image:: https://img.shields.io/badge/maturity-{{ development_status | replace("-", "--") | urlencode }}-brightgreen.png + :target: https://odoo-community.org/page/development-status + :alt: {{ development_status | title }} + +.. |badge_license| image:: https://img.shields.io/badge/license-{{ manifest.license | d("Unknown") | replace("-", "--") | urlencode }}-blue.png + :alt: {{ manifest.license | d("Unknown") }} + +|badge_devstat| |badge_license| + +{{ fragments.get('DESCRIPTION', '') }} +{% if development_status == 'alpha' -%} + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +{% endif -%} + +**Table of contents** + +.. contents:: + :local: + +{{ fragment('INSTALL', 'Installation') }} +{{- fragment('CONFIGURE', 'Configuration') }} +{{- fragment('USAGE', 'Usage') }} +{{- fragment('DEVELOP', 'Development') }} +{{- fragment('ROADMAP', 'Known issues / Roadmap') -}} +{{- fragment('HISTORY', 'Changelog') -}} + +Credits +{{ "=======" }} + +{% if authors -%} +Authors +~~~~~~~ + +{% for author in authors if author -%} +* {{ author }} +{% endfor %} +{% endif -%} + +{{ fragment('CONTRIBUTORS', 'Contributors', sub='~') }} +{{- fragment('CREDITS', 'Other credits', sub='~') -}} +Maintainers +~~~~~~~~~~~ + +This module is maintained by {{ org_name }}. + +Contact the maintainer through their official support channels in case you find +any issues with this module. +{% if manifest.maintainers %} + +{% for maintainer in manifest.maintainers %} +.. |maintainer-{{ maintainer }}| image:: https://github.com/{{ maintainer }}.png?size=40px + :target: https://github.com/{{ maintainer }} + :alt: {{ maintainer}} +{%- endfor %} + +Current maintainer{% if manifest.maintainers|length > 1 %}s{% endif %}: + +{% for maintainer in manifest.maintainers %}|maintainer-{{ maintainer }}|{% if not loop.last %} {% endif %}{% endfor %} +{% endif %} +{% endraw -%} diff --git a/.module-readme.rst.j2 b/{% if odoo_version >= 13 %}.module-readme.rst.j2{% endif %}.jinja similarity index 99% rename from .module-readme.rst.j2 rename to {% if odoo_version >= 13 %}.module-readme.rst.j2{% endif %}.jinja index 6b9a75c1..7e26a5bb 100644 --- a/.module-readme.rst.j2 +++ b/{% if odoo_version >= 13 %}.module-readme.rst.j2{% endif %}.jinja @@ -1,3 +1,4 @@ +{% raw -%} {%- macro fragment(name, title, sub='=') %} {%- if name in fragments %} {{- title }} @@ -85,3 +86,4 @@ Current maintainer{% if manifest.maintainers|length > 1 %}s{% endif %}: {% for maintainer in manifest.maintainers %}|maintainer-{{ maintainer }}|{% if not loop.last %} {% endif %}{% endfor %} {% endif %} +{% endraw -%} diff --git a/.pre-commit-config.yaml.jinja b/{% if odoo_version >= 13 %}.pre-commit-config.yaml{% endif %}.jinja similarity index 76% rename from .pre-commit-config.yaml.jinja rename to {% if odoo_version >= 13 %}.pre-commit-config.yaml{% endif %}.jinja index 4858a838..a35c27c6 100644 --- a/.pre-commit-config.yaml.jinja +++ b/{% if odoo_version >= 13 %}.pre-commit-config.yaml{% endif %}.jinja @@ -60,45 +60,12 @@ repos: - id: oca-checks-po args: ["--fix"] {% endif -%} - {% if odoo_version >= 13 -%} - repo: https://github.com/astral-sh/ruff-pre-commit rev: {{ proj_rev.ruff }} hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - {% else -%} - - repo: https://github.com/psf/black - rev: 23.9.1 - hooks: - - id: black - additional_dependencies: ["click<=8.1.7"] - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort except __init__.py - args: [--settings, .] - exclude: /__init__\.py$ - - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - name: flake8 except __init__.py, __manifest__.py - args: ["--extend-ignore=B023"] - exclude: /__(?:init|manifest)__\.py$ - additional_dependencies: ["flake8-bugbear==23.7.10", "importlib-metadata<=6.8.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==23.7.10", "importlib-metadata<=6.8.0"] - - id: flake8 - name: flake8 only __manifest__.py - args: ["--extend-ignore=B018"] # ignore found useless expression in __manifest__.py - files: /__manifest__\.py$ - additional_dependencies: ["flake8-bugbear==23.7.10", "importlib-metadata<=6.8.0"] - {% endif -%} - repo: https://github.com/pre-commit/mirrors-prettier # HACK https://github.com/prettier/prettier/issues/15696 rev: v2.7.1 @@ -115,13 +82,9 @@ repos: 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 diff --git a/.ruff.toml.jinja b/{% if odoo_version >= 13 %}.ruff.toml{% endif %}.jinja similarity index 100% rename from .ruff.toml.jinja rename to {% if odoo_version >= 13 %}.ruff.toml{% endif %}.jinja