Skip to content

Commit

Permalink
[REF] cfg: bump pylint-odoo to v9.0.4 (#127)
Browse files Browse the repository at this point in the history
* [REF] cfg: bump pylint-odoo to v9.0.4

pylint v3.0.0 was released and pylint-odoo has been updated to work with
it. A new major version of pylint-odoo has therefore been released.

BREAKING CHANGE: support for python < 3.7 (everything below py3.8) has
been dropped since pylint no longer supports it upstream either.

* [FIX] core: simplify != 0 comparisons

New pylint 3.0.0 release was raising
use-implicit-booleaness-not-comparison-to-zero errors. They have been
corrected.

* [REF] cfg: make `use-implicit-boleaness-*` optional

These checks were previously part of a pylint extension so they had to
be manually loaded as plugins. They now form part of the core and simply
need to be enabled. After internal discussion it was decided to make
them optional.

* [REF] cfg: drop dead messages from pylintrc

Messages that were not generated by pylint-odoo anymore were removed
from the respective configuration files to reduce clutter.

* [IMP] cfg: update autofix hooks

This commit updates the version for all hooks in the autofix
configuration to their latest release.

It also moves isort's configuration on the .yaml itself to
the respective configuration file for the tool since that
is the prefered way.

* [IMP] cfg: update optional hooks & flake config

This commit updates the version of all optional hooks to their latest
release. flake8-bugbear which flake8 uses has been updated as well.

flake8 configuration was updated as well, since this new version does
not support inline commnets.

B018 which checks for useless expressions was also supressed on
__manifest__.py files.

* [IMP] cfg: update mandatory hook versions & flake config

All the versions for hooks in .pre-commit-config.yaml, known as
mandatory hooks, have been updated.

flake8 configuration had to be modified since this specific project
has two config sources, setup.cfg and flake8, the [flake8] section in
setup.cfg had to be removed since it was overriding the one set in
.flake8.

Also removed the exclude line, since some other messages may apply to
__init__.py, and __unported__ files wont even be checked because
pre-commit excludes them (not a python file).

* [IMP] tests: validate pylintrc files

A test has been added to verify there are no duplicate messages in a
pylintrc enable/disable section and that all messages actually exist.
This makes it easier to keep clean pylintrc files by automating some
basic checks on them.

* [FIX] cfg: remove duplicate message in .pylintrc files

* [REF] cfg: cleanup pylintrc, remove non-existent messages

This commit updates pylintrc configuration files used for pylint. It
removes a bunch of messages that don't exist anymore or updates their
name in cases when they were renamed. Checks removed were either:

* renamed
* applied to python 2
* are now performed by other tools
* applied to really old versions of odoo

Some cases which have official documentation are the  following:

* bad-continuation and bad-whitespace were removed in pylint 2.6
  https://pylint.pycqa.org/en/v2.11.1/whatsnew/2.6.html
* bad-optional-value was split into useless-option-value and unknown-option-value
  https://pylint.pycqa.org/en/latest/user_guide/messages/error/bad-option-value.html
* missing-docstring split into three checks (module,class,function)
  https://pylint.pycqa.org/en/latest/user_guide/messages/convention/missing-docstring.html
* no-self-use is redundant since the extension that creates it is not used
* no-init was removed
  pylint-dev/pylint#6373
* useless-super-delegation was renamed to useless-parent-delegation
* broad-except renamed and a new check added:
  pylint-dev/pylint#7709

* [REF] cfg: (flake8) disable B905,B907 and make E741 optional

* [REF] pylintrc: make  optional

* [REF] flake8: ignore E501

This check was not being generated as mandatory previously, therefore it
has been ignored. It is already covered by other checks anyways.

* [REF] cfg: update pylint-odoo to v9.0.4

* [REV]: keep black in same version

This keeps the performance improvement of using a mypyc compiled
version with no new style changes, those will be applied at a later
time.
  • Loading branch information
antonag32 authored Nov 23, 2023
1 parent be1f1f3 commit c50e425
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, windows-latest, macos-latest]
tox_env: ['py']
include:
Expand Down
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[bdist_wheel]
universal = 1

[flake8]
max-line-length = 140
exclude = .tox,.eggs,ci/templates,build,dist,resources

[tool:isort]
force_single_line = True
line_length = 120
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def read(*names, **kwargs):
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -84,7 +83,7 @@ def read(*names, **kwargs):
keywords=[
# eg: 'keyword1', 'keyword2', 'keyword3',
],
python_requires=">=3.7",
python_requires=">=3.8",
install_requires=generate_dependencies(),
extras_require={
# eg:
Expand Down
4 changes: 2 additions & 2 deletions src/pre_commit_vauxoo/cfg/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# W503 changed by W504 and OCA prefers allow both
# F401 is legal in odoo __init__.py files
# E203 (whitespace before ':') is handled by black and it doesn't consider black syntax like:
# E741 do not use variables named ‘l’, ‘O’, or ‘I’
# chunk = records[index : index + chunk_size]
ignore = E123,E133,E203,E226,E241,E242,F811,F601,W503,W504
ignore = E123,E133,E203,E226,E241,E242,E501,E741,F811,F601,W503,W504
max-line-length = 119
per-file-ignores=
__init__.py:F401
exclude = __unported__,__init__.py
jobs = 0
25 changes: 14 additions & 11 deletions src/pre_commit_vauxoo/cfg/.flake8-optional
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ jobs = 0
# B = bugbear
# B9 = bugbear opinionated (incl line length +10% tolerance)
select = C,E,F,W,B,B9
ignore =
E203 # whitespace before ':' (black behaviour)
E501 # E501: flake8 line length (covered by bugbear B950)
W503 # W503: line break before binary operator (black behaviour)
W504 # W504: line break after binary operator (black behaviour?)
E241 # E241: E241 multiple spaces after ',' (Better autofixing)
B023 # B023: Function definition does not bind loop variable 'item'. (Odoo needs it [self.filtered(lambda l: l.item_id == item) for item in items])
E226 # E226: missing whitespace around arithmetic operator (Better autofixing)
B904 # B904: Within an `except` clause, raise exceptions with `raise (It is valid for us)
E123 # E123: closing bracket does not match indentation of opening bracket's line (Better autofixing)
E275 # E275: missing whitespace after keyword (Better autofixing)
# E203 whitespace before ':' (black behaviour)
# E501: flake8 line length (covered by bugbear B950)
# W503: line break before binary operator (black behaviour)
# W504: line break after binary operator (black behaviour?)
# E241: E241 multiple spaces after ',' (Better autofixing)
# B023: Function definition does not bind loop variable 'item'. (Odoo needs it [self.filtered(lambda l: l.item_id == item) for item in items])
# E226: missing whitespace around arithmetic operator (Better autofixing)
# B904: Within an `except` clause, raise exceptions with `raise (It is valid for us)
# E123: closing bracket does not match indentation of opening bracket's line (Better autofixing)
# E275: missing whitespace after keyword (Better autofixing)
# B905: zip(strict=True) only works in python >= 3.10
# B907: We sometimes quote for stylistic purposes
# F401: imported but unused (like __init__ already works)
ignore = E203,E501,W503,W504,E241,B023,E226,B904,B905,B907,E123,E275
per-file-ignores =
__init__.py:F401
__manifest__.py:B018
1 change: 1 addition & 0 deletions src/pre_commit_vauxoo/cfg/.isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ known_odoo_addons=odoo.addons
sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY
ensure_newline_before_comments = True
skip_glob=**/__init__.py
20 changes: 8 additions & 12 deletions src/pre_commit_vauxoo/cfg/.pre-commit-config-autofix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ default_language_version:
python: python3
node: "14.13.0"
repos:
- repo: https://github.com/psf/black
- repo: https://github.com/psf/black-pre-commit-mirror.git
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/myint/autoflake
rev: v1.7.7
rev: v2.2.1
hooks:
- id: autoflake
args:
Expand All @@ -45,7 +45,7 @@ repos:
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v3.0.3
hooks:
- id: prettier
name: prettier (with plugin-xml)
Expand All @@ -56,7 +56,7 @@ repos:
- --plugin=@prettier/plugin-xml
files: \.(js|xml)$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
# exclude autogenerated files
Expand All @@ -69,25 +69,21 @@ repos:
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
- repo: https://github.com/PyCQA/isort
rev: 5.11.5
rev: 5.12.0
hooks:
- id: isort
name: isort (except __init__.py)
args:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.1
rev: v1.5.4
hooks:
- id: remove-tabs
exclude: (Makefile|debian/rules|.gitmodules|\.po|\.pot)(\.in)?$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.27.0
rev: v8.51.0
hooks:
- id: eslint
name: javascript lints
Expand Down
8 changes: 4 additions & 4 deletions src/pre_commit_vauxoo/cfg/.pre-commit-config-optional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ default_language_version:
node: "14.13.0"
repos:
- repo: https://github.com/OCA/pylint-odoo
rev: v8.0.21
rev: v9.0.4
hooks:
- id: pylint_odoo
name: pylint optional checks
Expand All @@ -43,16 +43,16 @@ repos:
- id: oca-checks-odoo-module
- id: oca-checks-po
- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
rev: v1.1.1
hooks:
- id: doc8
name: RST lint
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.1.0
hooks:
- id: flake8
name: flake8 + bugbear optional checks
additional_dependencies: ["flake8-bugbear==22.7.1"]
additional_dependencies: ["flake8-bugbear==23.9.16"]
args:
- --config=.flake8-optional
- repo: https://github.com/PyCQA/bandit
Expand Down
8 changes: 4 additions & 4 deletions src/pre_commit_vauxoo/cfg/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ default_language_version:
node: "14.13.0"
repos:
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 6.1.0
hooks:
- id: flake8
name: flake8 mandatory checks
- repo: https://github.com/OCA/pylint-odoo
rev: v8.0.21
rev: v9.0.0
hooks:
- id: pylint_odoo
name: pylint mandatory checks
args:
# External scripts
- --disable=R0000
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.13.0
rev: v8.51.0
hooks:
- id: eslint
name: javascript mandatory checks
Expand All @@ -61,7 +61,7 @@ repos:
types: [jinja]
files: ^deactivate\.jinja$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.5.0
hooks:
- id: debug-statements
- id: check-case-conflict
Expand Down
Loading

0 comments on commit c50e425

Please sign in to comment.