Skip to content

Instantly share code, notes, and snippets.

@rockavoldy
Last active September 23, 2022 03:31
Show Gist options
  • Save rockavoldy/f6e19050849ab4942e18f0f67780f5fc to your computer and use it in GitHub Desktop.
Save rockavoldy/f6e19050849ab4942e18f0f67780f5fc to your computer and use it in GitHub Desktop.
pylint things

Pylint for odoo

  1. Install pylint and pylint-odoo with pip
python3 -m pip install pylint
# and install plugin pylint-odoo from OCA repository
python3 -m pip install --upgrade git+https://github.com/oca/pylint-odoo.git
  1. pylint-odoo already have default configuration that you can run easily with
python3 -m pylint --load-plugins=pylint_odoo -d all -e odoolint <your_custom_addons_directory>
# For example
python3 -m pylint --load-plugins=pylint_odoo -d all -e odoolint custom-addons/pcs_payment_tripay

flag --load-plugins=pylint_odoo means we want to load plugin pylint-odoo flag -d all means we want to disable all configuration then flag -e odoolint means we want to enable configuration from odoolint Note: by default, you can find odoolint default configuration here

[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=Port Cities
manifest_required_keys=name,summary,description,author,website,version,depends
manifest_deprecated_keys=active
valid_odoo_versions=13.0
[MESSAGES CONTROL]
disable=all
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,
development-status-allowed,
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-author,
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,
no-utf8-coding-comment,
odoo-addons-relative-import,
old-api7-method-defined,
redefined-builtin,
too-complex,
unnecessary-utf8-coding-comment
[REPORTS]
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=colorized
reports=no
name: Test
on:
pull_request:
branches:
- main
jobs:
test_pr_with_pylint:
name: "Test PR with pylint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install python 3.8.13
uses: actions/setup-python@v4
with:
python-version: '3.8.13'
- name: Install pylint and pylint-odoo
run: |
python3 -m pip install setuptools wheel
python3 -m pip install pylint
python3 -m pip install --upgrade git+https://github.com/oca/pylint-odoo.git
- name: Run tests
run: |
python3 -m pylint --rcfile=.pylintrc $(find . -name "*.py" | xargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment