Skip to content

Commit 354ebf9

Browse files
committed
[IMP] Update pre-commit to current OCA standards, dob compatible
1 parent 24bd079 commit 354ebf9

File tree

3 files changed

+249
-25
lines changed

3 files changed

+249
-25
lines changed

.pre-commit-config.yaml

Lines changed: 94 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,65 @@
1+
exclude: |
2+
(?x)
3+
# NOT INSTALLABLE ADDONS
4+
# END NOT INSTALLABLE ADDONS
5+
# Files and folders generated by bots, to avoid loops
6+
^setup/|/static/description/index\.html$|
7+
# We don't want to mess with tool-generated files
8+
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
9+
# Maybe reactivate this when all README files include prettier ignore tags?
10+
^README\.md$|
11+
# Library files can have extraneous formatting (even minimized)
12+
/static/(src/)?lib/|
13+
# Repos using Sphinx to generate docs don't need prettying
14+
^docs/_templates/.*\.html$|
15+
# You don't usually want a bot to modify your legal texts
16+
(LICENSE.*|COPYING.*)|
17+
# Exclude external addons
18+
odoo/src/ext_addons/|
19+
odoo.versions.yaml
20+
default_language_version:
21+
python: python3
22+
node: "14.18.0"
123
repos:
24+
- repo: local
25+
hooks:
26+
# These files are most likely copier diff rejection junks; if found,
27+
# review them manually, fix the problem (if needed) and remove them
28+
- id: forbidden-files
29+
name: forbidden files
30+
entry: found forbidden files; remove them
31+
language: fail
32+
files: "\\.rej$"
33+
- repo: https://github.com/myint/autoflake
34+
rev: v1.4
35+
hooks:
36+
- id: autoflake
37+
args:
38+
- --expand-star-imports
39+
- --ignore-init-module-imports
40+
- --in-place
41+
- --remove-all-unused-imports
42+
- --remove-duplicate-keys
43+
- --remove-unused-variables
244
- repo: https://github.com/psf/black
3-
rev: 20.8b1
45+
rev: 21.9b0
446
hooks:
547
- id: black
6-
748
- repo: https://github.com/pre-commit/mirrors-prettier
8-
rev: v2.1.2
49+
rev: v2.4.1
950
hooks:
1051
- id: prettier
11-
name: prettier + plugin-xml
52+
name: prettier (with plugin-xml)
1253
additional_dependencies:
13-
- "prettier@2.1.2"
14-
- "@prettier/plugin-xml@0.12.0"
54+
- "prettier@2.4.1"
55+
- "@prettier/plugin-xml@1.1.0"
1556
args:
1657
- --config=odoo/.prettierrc.yml
1758
- --plugin=@prettier/plugin-xml
1859
- --ignore-path=odoo/.prettierignore
19-
60+
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
2061
- repo: https://github.com/pre-commit/mirrors-eslint
21-
rev: v7.8.1
62+
rev: v7.32.0
2263
hooks:
2364
- id: eslint
2465
verbose: true
@@ -27,31 +68,62 @@ repos:
2768
- --fix
2869
- --config=odoo/.eslintrc.yml
2970
- --ignore-path=odoo/.eslintignore
30-
31-
- repo: https://gitlab.com/pycqa/flake8
32-
rev: 3.8.2
71+
- repo: https://github.com/pre-commit/pre-commit-hooks
72+
rev: v4.0.1
3373
hooks:
34-
- id: flake8
35-
additional_dependencies: [flake8-bugbear]
36-
args:
37-
- --config=odoo/.flake8
38-
74+
- id: trailing-whitespace
75+
# exclude autogenerated files
76+
exclude: /README\.rst$|\.pot?$
77+
- id: end-of-file-fixer
78+
# exclude autogenerated files
79+
exclude: /README\.rst$|\.pot?$
80+
- id: debug-statements
81+
- id: fix-encoding-pragma
82+
args: ["--remove"]
83+
- id: check-case-conflict
84+
- id: check-docstring-first
85+
- id: check-executables-have-shebangs
86+
- id: check-merge-conflict
87+
# exclude files where underlines are not distinguishable from merge conflicts
88+
exclude: /README\.rst$|^docs/.*\.rst$
89+
- id: check-symlinks
90+
- id: check-xml
91+
- id: mixed-line-ending
92+
args: ["--fix=lf"]
93+
- repo: https://github.com/asottile/pyupgrade
94+
rev: v2.29.0
95+
hooks:
96+
- id: pyupgrade
97+
args: ["--keep-percent-format"]
3998
- repo: https://github.com/PyCQA/isort
40-
rev: 5.5.1
99+
rev: 5.9.3
41100
hooks:
42101
- id: isort
43-
name: isort
102+
name: isort except __init__.py
103+
exclude: /__init__\.py$
44104
args:
45105
- --settings=odoo/
46-
106+
- repo: https://gitlab.com/PyCQA/flake8
107+
rev: 3.9.2
108+
hooks:
109+
- id: flake8
110+
name: flake8
111+
additional_dependencies: ["flake8-bugbear==21.9.2"]
112+
args:
113+
- --config=odoo/.flake8
47114
- repo: https://github.com/PyCQA/pylint
48-
rev: pylint-2.5.3
115+
rev: v2.11.1
49116
hooks:
50117
- id: pylint
51-
name: pylint
118+
name: pylint with optional checks
52119
args:
53120
- --rcfile=odoo/.pylintrc
54121
- --exit-zero
55122
verbose: true
56123
additional_dependencies: &pylint_deps
57-
- pylint-odoo==5.0.0
124+
- pylint-odoo==5.0.4
125+
- id: pylint
126+
name: pylint with mandatory checks
127+
args:
128+
- --rcfile=odoo/.pylintrc-mandatory
129+
additional_dependencies: *pylint_deps

odoo/.pylintrc

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@ score=n
44

55
[ODOOLINT]
66
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
7+
manifest_required_authors=Odoo Community Association (OCA)
78
manifest_required_keys=license
89
manifest_deprecated_keys=description,active
910
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
11+
valid_odoo_versions=15.0
1012

1113
[MESSAGES CONTROL]
1214
disable=all
1315

16+
# This .pylintrc contains optional AND mandatory checks and is meant to be
17+
# loaded in an IDE to have it check everything, in the hope this will make
18+
# optional checks more visible to contributors who otherwise never look at a
19+
# green travis to see optional checks that failed.
20+
# .pylintrc-mandatory containing only mandatory checks is used the pre-commit
21+
# config as a blocking check.
22+
1423
enable=anomalous-backslash-in-string,
1524
api-one-deprecated,
1625
api-one-multi-together,
@@ -19,6 +28,7 @@ enable=anomalous-backslash-in-string,
1928
class-camelcase,
2029
dangerous-default-value,
2130
dangerous-view-replace-wo-priority,
31+
development-status-allowed,
2232
duplicate-id-csv,
2333
duplicate-key,
2434
duplicate-xml-fields,
@@ -35,8 +45,6 @@ enable=anomalous-backslash-in-string,
3545
method-inverse,
3646
method-required-super,
3747
method-search,
38-
missing-import-error,
39-
missing-manifest-dependency,
4048
openerp-exception-warning,
4149
pointless-statement,
4250
pointless-string-statement,
@@ -54,7 +62,56 @@ enable=anomalous-backslash-in-string,
5462
unreachable,
5563
use-vim-comment,
5664
wrong-tabs-instead-of-spaces,
57-
xml-syntax-error
65+
xml-syntax-error,
66+
attribute-string-redundant,
67+
character-not-valid-in-resource-link,
68+
consider-merging-classes-inherited,
69+
context-overridden,
70+
create-user-wo-reset-password,
71+
dangerous-filter-wo-user,
72+
dangerous-qweb-replace-wo-priority,
73+
deprecated-data-xml-node,
74+
deprecated-openerp-xml-node,
75+
duplicate-po-message-definition,
76+
except-pass,
77+
file-not-used,
78+
invalid-commit,
79+
manifest-maintainers-list,
80+
missing-newline-extrafiles,
81+
missing-readme,
82+
missing-return,
83+
odoo-addons-relative-import,
84+
old-api7-method-defined,
85+
po-msgstr-variables,
86+
po-syntax-error,
87+
renamed-field-parameter,
88+
resource-not-exist,
89+
str-format-used,
90+
test-folder-imported,
91+
translation-contains-variable,
92+
translation-positional-used,
93+
unnecessary-utf8-coding-comment,
94+
website-manifest-key-not-valid-uri,
95+
xml-attribute-translatable,
96+
xml-deprecated-qweb-directive,
97+
xml-deprecated-tree-attribute,
98+
# messages that do not cause the lint step to fail
99+
consider-merging-classes-inherited,
100+
create-user-wo-reset-password,
101+
dangerous-filter-wo-user,
102+
deprecated-module,
103+
file-not-used,
104+
invalid-commit,
105+
missing-manifest-dependency,
106+
missing-newline-extrafiles,
107+
missing-readme,
108+
no-utf8-coding-comment,
109+
odoo-addons-relative-import,
110+
old-api7-method-defined,
111+
redefined-builtin,
112+
too-complex,
113+
unnecessary-utf8-coding-comment
114+
58115

59116
[REPORTS]
60117
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}

odoo/.pylintrc-mandatory

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
[MASTER]
2+
load-plugins=pylint_odoo
3+
score=n
4+
5+
[ODOOLINT]
6+
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
7+
manifest_required_authors=Odoo Community Association (OCA)
8+
manifest_required_keys=license
9+
manifest_deprecated_keys=description,active
10+
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
11+
valid_odoo_versions=15.0
12+
13+
[MESSAGES CONTROL]
14+
disable=all
15+
16+
enable=anomalous-backslash-in-string,
17+
api-one-deprecated,
18+
api-one-multi-together,
19+
assignment-from-none,
20+
attribute-deprecated,
21+
class-camelcase,
22+
dangerous-default-value,
23+
dangerous-view-replace-wo-priority,
24+
development-status-allowed,
25+
duplicate-id-csv,
26+
duplicate-key,
27+
duplicate-xml-fields,
28+
duplicate-xml-record-id,
29+
eval-referenced,
30+
eval-used,
31+
incoherent-interpreter-exec-perm,
32+
license-allowed,
33+
manifest-author-string,
34+
manifest-deprecated-key,
35+
manifest-required-key,
36+
manifest-version-format,
37+
method-compute,
38+
method-inverse,
39+
method-required-super,
40+
method-search,
41+
openerp-exception-warning,
42+
pointless-statement,
43+
pointless-string-statement,
44+
print-used,
45+
redundant-keyword-arg,
46+
redundant-modulename-xml,
47+
reimported,
48+
relative-import,
49+
return-in-init,
50+
rst-syntax-error,
51+
sql-injection,
52+
too-few-format-args,
53+
translation-field,
54+
translation-required,
55+
unreachable,
56+
use-vim-comment,
57+
wrong-tabs-instead-of-spaces,
58+
xml-syntax-error,
59+
attribute-string-redundant,
60+
character-not-valid-in-resource-link,
61+
consider-merging-classes-inherited,
62+
context-overridden,
63+
create-user-wo-reset-password,
64+
dangerous-filter-wo-user,
65+
dangerous-qweb-replace-wo-priority,
66+
deprecated-data-xml-node,
67+
deprecated-openerp-xml-node,
68+
duplicate-po-message-definition,
69+
except-pass,
70+
file-not-used,
71+
invalid-commit,
72+
manifest-maintainers-list,
73+
missing-newline-extrafiles,
74+
missing-readme,
75+
missing-return,
76+
odoo-addons-relative-import,
77+
old-api7-method-defined,
78+
po-msgstr-variables,
79+
po-syntax-error,
80+
renamed-field-parameter,
81+
resource-not-exist,
82+
str-format-used,
83+
test-folder-imported,
84+
translation-contains-variable,
85+
translation-positional-used,
86+
unnecessary-utf8-coding-comment,
87+
website-manifest-key-not-valid-uri,
88+
xml-attribute-translatable,
89+
xml-deprecated-qweb-directive,
90+
xml-deprecated-tree-attribute
91+
92+
[REPORTS]
93+
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
94+
output-format=colorized
95+
reports=no

0 commit comments

Comments
 (0)