Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] MQT-compatible pre-commit + GitHub actions for 10, 11, 12 #117

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ odoo_version:
type: float
default: 15.0
choices:
- 10.0
- 11.0
- 12.0
- 13.0
- 14.0
- 15.0
Expand Down
4 changes: 4 additions & 0 deletions src/.flake8 → src/.flake8.jinja
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{%- if odoo_version < 13 %}
{%- include "version-specific/mqt-compat/.flake8" %}
{%- else %}
[flake8]
max-line-length = 88
max-complexity = 16
Expand All @@ -10,3 +13,4 @@ select = C,E,F,W,B,B9
ignore = E203,E501,W503
per-file-ignores=
__init__.py:F401
{%- endif %}
5 changes: 4 additions & 1 deletion src/.pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
{%- endif %}

{#- Older versions that differ a lot have their own hardcoded templates for readability #}
{%- if odoo_version < 14 %}
{%- if odoo_version < 13 %}
{%- include "version-specific/mqt-compat/.pre-commit-config.yaml.jinja" %}

{%- elif odoo_version < 14 %}
{%- include "version-specific/%s/.pre-commit-config.yaml" % odoo_version %}

{#- Newer versions without hacks are rendered here directly #}
Expand Down
4 changes: 4 additions & 0 deletions src/.pylintrc-mandatory.jinja
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{%- if odoo_version < 13 %}
{%- include "version-specific/mqt-compat/.pylintrc-mandatory.jinja" %}
{%- else %}
[MASTER]
load-plugins=pylint_odoo
score=n
Expand Down Expand Up @@ -97,3 +100,4 @@ enable=anomalous-backslash-in-string,
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no
{%- endif %}
4 changes: 4 additions & 0 deletions src/.pylintrc.jinja
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{%- if odoo_version < 13 %}
{%- include "version-specific/mqt-compat/.pylintrc.jinja" %}
{%- else %}
{% extends "src/.pylintrc-mandatory.jinja" %}
{% block note %}
# This .pylintrc contains optional AND mandatory checks and is meant to be
Expand Down Expand Up @@ -25,3 +28,4 @@
too-complex,
unnecessary-utf8-coding-comment
{% endblock %}
{%- endif %}
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions version-specific/mqt-compat/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
# E123,E133,E226,E241,E242 are ignored by default by pep8 and flake8
# F811 is legal in odoo 8 when we implement 2 interfaces for a method
# F999 pylint support this case with expected tests
# W503 changed by W504 and OCA prefers allow both
# E203: whitespace before ':' (black behaviour and not pep8 compliant)
ignore = E123,E133,E226,E241,E242,F811,F601,W503,W504,E203
Comment on lines +4 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F999 doesn't exist. I think F601 is intended?

max-line-length = 88
per-file-ignores=
__init__.py:F401
Comment on lines +9 to +10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that can be removed because the old flake8 oca/maintainer-quality-tools is using does not support per-file-ignores.

61 changes: 61 additions & 0 deletions version-specific/mqt-compat/.pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
# We don't want to mess with tool-generated files
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
# Maybe reactivate this when all README files include prettier ignore tags?
^README\.md$|
# Library files can have extraneous formatting (even minimized)
/static/(src/)?lib/|
# Repos using Sphinx to generate docs don't need prettying
^docs/_templates/.*\.html$|
# You don't usually want a bot to modify your legal texts
(LICENSE.*|COPYING.*)
default_language_version:
python: python3
repos:
- repo: https://github.com/oca/maintainer-tools
rev: ab1d7f6
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
- id: oca-fix-manifest-website
args: ["https://github.com/OCA/{{ repo_slug }}"]
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.0.6
hooks:
- id: setuptools-odoo-make-default
{%- if generate_requirements_txt %}
- id: setuptools-odoo-get-requirements
args:
- --output
- requirements.txt
- --header
- "# generated from manifests external_dependencies"
{%- endif %}
- repo: https://github.com/OCA/mirrors-flake8
rev: v3.4.1
hooks:
- id: flake8
language_version: python{% if odoo_version < 11 %}2{% else %}3{% endif %}
name: flake8 excluding __init__.py
exclude: __init__\.py
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.5.3
hooks:
- id: pylint
name: pylint with optional checks
args:
- --rcfile=.pylintrc
- --exit-zero
verbose: true
additional_dependencies: &pylint_deps
- pylint-odoo==3.5.0
- id: pylint
name: pylint with mandatory checks
args:
- --rcfile=.pylintrc-mandatory
additional_dependencies: *pylint_deps
65 changes: 65 additions & 0 deletions version-specific/mqt-compat/.pylintrc-mandatory.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[MASTER]
load-plugins=pylint_odoo
score=n

[ODOOLINT]
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest_required_authors=Odoo Community Association (OCA)
manifest_required_keys=license
manifest_deprecated_keys=description,active
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid_odoo_versions={{ odoo_version }}

[MESSAGES CONTROL]
disable=all

# Enable message and code:
# anomalous-backslash-in-string - W1401
# assignment-from-none - W1111
# dangerous-default-value - W0102
# duplicate-key - W0109
# missing-import-error - W7935
# missing-manifest-dependency - W7936
# pointless-statement - W0104
# pointless-string-statement - W0105
# print-statement - E1601
# redundant-keyword-arg - E1124
# reimported - W0404
# relative-import - W0403
# return-in-init - E0101
# rst-syntax-error - E7901
# too-few-format-args - E1306
# unreachable - W0101

enable=anomalous-backslash-in-string,
assignment-from-none,
dangerous-default-value,
development-status-allowed,
duplicate-key,
duplicate-po-message-definition,
missing-import-error,
missing-manifest-dependency,
po-msgstr-variables,
po-syntax-error,
pointless-statement,
pointless-string-statement,
print-used,
redundant-keyword-arg,
reimported,
relative-import,
return-in-init,
rst-syntax-error,
too-few-format-args,
unreachable,
eval-used,
eval-referenced,
license-allowed,
manifest-author-string,
manifest-required-author,
manifest-required-key,
manifest-version-format,

[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no
100 changes: 100 additions & 0 deletions version-specific/mqt-compat/.pylintrc.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
[MASTER]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd probably be nice to use the same {% extends "src/.pylintrc-mandatory.jinja" %} mechanism here as in src/.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposal in coopiteasy@9ef6115

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no strong opinion on this. As long as this does the same as the pylint configs of oca/maintainer-quality-tools.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does basically the same, except .pylintrc now also repeats the .pylintrc-mandatory tests, which I think is desirable for local development.

load-plugins=pylint_odoo
score=n

[ODOOLINT]
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest_required_authors=Odoo Community Association (OCA)
manifest_required_keys=license
manifest_deprecated_keys=description,active
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
valid_odoo_versions={{ odoo_version }}

[MESSAGES CONTROL]
disable=all

# Beta message and code:
# api-one-deprecated - W8104
# api-one-multi-together - W8101
# attribute-deprecated - W8105
# class-camelcase - C8104
# create-user-wo-reset-password - W7905
# consider-merging-classes-inherited - R7980
# copy-wo-api-one - W8102
# dangerous-filter-wo-user - W7901
# dangerous-view-replace-wo-priority - W7940
# deprecated-module - W0402
# duplicate-id-csv - W7906
# duplicate-xml-fields - W7907
# duplicate-xml-record-id - W7902
# file-not-used - W7930
# incoherent-interpreter-exec-perm - W8201
# invalid-commit - E8102
# javascript-lint - W7903
# manifest-deprecated-key - C8103
# method-compute - C8108
# method-inverse - C8110
# method-required-super - W8106
# method-search - C8109
# missing-newline-extrafiles - W7908
# missing-readme - C7902
# no-utf8-coding-comment - C8201
# unnecessary-utf8-coding-comment - C8202
# odoo-addons-relative-import - W7950
# old-api7-method-defined - R8110
# openerp-exception-warning - R8101
# redundant-modulename-xml - W7909
# sql-injection - E8103
# too-complex - C0901
# translation-field - W8103
# translation-required - C8107
# use-vim-comment - W8202
# wrong-tabs-instead-of-spaces - W7910
# xml-syntax-error - E7902

enable=api-one-deprecated,
api-one-multi-together,
attribute-deprecated,
class-camelcase,
create-user-wo-reset-password,
consider-merging-classes-inherited,
copy-wo-api-one,
dangerous-filter-wo-user,
dangerous-view-replace-wo-priority,
deprecated-module,
duplicate-id-csv,
duplicate-po-message-definition,
duplicate-xml-fields,
duplicate-xml-record-id,
file-not-used,
incoherent-interpreter-exec-perm,
invalid-commit,
javascript-lint,
manifest-deprecated-key,
method-compute,
method-inverse,
method-required-super,
method-search,
missing-newline-extrafiles,
missing-readme,
po-msgstr-variables,
po-syntax-error,
no-utf8-coding-comment,
unnecessary-utf8-coding-comment,
odoo-addons-relative-import,
old-api7-method-defined,
openerp-exception-warning,
redefined-builtin,
redundant-modulename-xml,
sql-injection,
too-complex,
translation-field,
translation-required,
use-vim-comment,
wrong-tabs-instead-of-spaces,
xml-syntax-error,

[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no