Skip to content

Commit f76d19e

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

3 files changed

Lines changed: 245 additions & 26 deletions

File tree

.pre-commit-config.yaml

Lines changed: 95 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,66 @@
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+
# Exclude container config file, especially the generated ones
20+
^odoo/*.*
21+
default_language_version:
22+
python: python3
23+
node: "14.18.0"
124
repos:
25+
- repo: local
26+
hooks:
27+
# These files are most likely copier diff rejection junks; if found,
28+
# review them manually, fix the problem (if needed) and remove them
29+
- id: forbidden-files
30+
name: forbidden files
31+
entry: found forbidden files; remove them
32+
language: fail
33+
files: "\\.rej$"
34+
- repo: https://github.com/myint/autoflake
35+
rev: v1.4
36+
hooks:
37+
- id: autoflake
38+
args:
39+
- --expand-star-imports
40+
- --ignore-init-module-imports
41+
- --in-place
42+
- --remove-all-unused-imports
43+
- --remove-duplicate-keys
44+
- --remove-unused-variables
245
- repo: https://github.com/psf/black
3-
rev: 20.8b1
46+
rev: 21.9b0
447
hooks:
548
- id: black
6-
749
- repo: https://github.com/pre-commit/mirrors-prettier
8-
rev: v2.1.2
50+
rev: v2.4.1
951
hooks:
1052
- id: prettier
11-
name: prettier + plugin-xml
53+
name: prettier (with plugin-xml)
1254
additional_dependencies:
13-
- "prettier@2.1.2"
14-
- "@prettier/plugin-xml@0.12.0"
55+
- "prettier@2.4.1"
56+
- "@prettier/plugin-xml@1.1.0"
1557
args:
1658
- --config=odoo/.prettierrc.yml
1759
- --plugin=@prettier/plugin-xml
1860
- --ignore-path=odoo/.prettierignore
19-
61+
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
2062
- repo: https://github.com/pre-commit/mirrors-eslint
21-
rev: v7.8.1
63+
rev: v7.32.0
2264
hooks:
2365
- id: eslint
2466
verbose: true
@@ -27,31 +69,62 @@ repos:
2769
- --fix
2870
- --config=odoo/.eslintrc.yml
2971
- --ignore-path=odoo/.eslintignore
30-
31-
- repo: https://gitlab.com/pycqa/flake8
32-
rev: 3.8.2
72+
- repo: https://github.com/pre-commit/pre-commit-hooks
73+
rev: v4.0.1
3374
hooks:
34-
- id: flake8
35-
additional_dependencies: [flake8-bugbear]
36-
args:
37-
- --config=odoo/.flake8
38-
75+
- id: trailing-whitespace
76+
# exclude autogenerated files
77+
exclude: /README\.rst$|\.pot?$
78+
- id: end-of-file-fixer
79+
# exclude autogenerated files
80+
exclude: /README\.rst$|\.pot?$
81+
- id: debug-statements
82+
- id: fix-encoding-pragma
83+
args: ["--remove"]
84+
- id: check-case-conflict
85+
- id: check-docstring-first
86+
- id: check-executables-have-shebangs
87+
- id: check-merge-conflict
88+
# exclude files where underlines are not distinguishable from merge conflicts
89+
exclude: /README\.rst$|^docs/.*\.rst$
90+
- id: check-symlinks
91+
- id: check-xml
92+
- id: mixed-line-ending
93+
args: ["--fix=lf"]
94+
- repo: https://github.com/asottile/pyupgrade
95+
rev: v2.29.0
96+
hooks:
97+
- id: pyupgrade
98+
args: ["--keep-percent-format"]
3999
- repo: https://github.com/PyCQA/isort
40-
rev: 5.5.1
100+
rev: 5.9.3
41101
hooks:
42102
- id: isort
43-
name: isort
103+
name: isort except __init__.py
104+
exclude: /__init__\.py$
44105
args:
45106
- --settings=odoo/
46-
107+
- repo: https://gitlab.com/PyCQA/flake8
108+
rev: 3.9.2
109+
hooks:
110+
- id: flake8
111+
name: flake8
112+
additional_dependencies: ["flake8-bugbear==21.9.2"]
113+
args:
114+
- --config=odoo/.flake8
47115
- repo: https://github.com/PyCQA/pylint
48-
rev: pylint-2.5.3
116+
rev: v2.11.1
49117
hooks:
50118
- id: pylint
51-
name: pylint
119+
name: pylint with optional checks
52120
args:
53121
- --rcfile=odoo/.pylintrc
54122
- --exit-zero
55123
verbose: true
56124
additional_dependencies: &pylint_deps
57-
- pylint-odoo==5.0.0
125+
- pylint-odoo==5.0.4
126+
- id: pylint
127+
name: pylint with mandatory checks
128+
args:
129+
- --rcfile=odoo/.pylintrc-mandatory
130+
additional_dependencies: *pylint_deps

odoo/.pylintrc

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ load-plugins=pylint_odoo
33
score=n
44

55
[ODOOLINT]
6-
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
76
manifest_required_keys=license
87
manifest_deprecated_keys=description,active
98
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
109

1110
[MESSAGES CONTROL]
1211
disable=all
1312

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

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

odoo/.pylintrc-mandatory

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

0 commit comments

Comments
 (0)