- Mailing Lists
- Contributors
- Re: Linting for 13.0 branches (using black and pre-commit)
Archives
- By thread 1419
-
By date
- August 2019 59
- September 2019 118
- October 2019 165
- November 2019 97
- December 2019 35
- January 2020 58
- February 2020 204
- March 2020 121
- April 2020 172
- May 2020 50
- June 2020 158
- July 2020 85
- August 2020 94
- September 2020 193
- October 2020 277
- November 2020 100
- December 2020 159
- January 2021 38
- February 2021 87
- March 2021 146
- April 2021 73
- May 2021 90
- June 2021 86
- July 2021 123
- August 2021 50
- September 2021 68
- October 2021 66
- November 2021 74
- December 2021 75
- January 2022 98
- February 2022 77
- March 2022 68
- April 2022 31
- May 2022 59
- June 2022 87
- July 2022 141
- August 2022 38
- September 2022 73
- October 2022 152
- November 2022 39
- December 2022 50
- January 2023 93
- February 2023 49
- March 2023 106
- April 2023 47
- May 2023 69
- June 2023 92
- July 2023 64
- August 2023 103
- September 2023 91
- October 2023 101
- November 2023 94
- December 2023 46
- January 2024 75
- February 2024 79
- March 2024 104
- April 2024 63
- May 2024 40
- June 2024 160
- July 2024 80
- August 2024 70
- September 2024 62
- October 2024 121
- November 2024 117
- December 2024 89
- January 2025 59
- February 2025 104
- March 2025 96
- April 2025 107
- May 2025 52
- June 2025 72
- July 2025 60
- August 2025 81
- September 2025 124
- October 2025 63
- November 2025 22
Contributors
Re: Linting for 13.0 branches (using black and pre-commit)
Dear contributors,The new configurations are in place for the 13.0 branches.The blog post has all the details.Side note: the travis configuration has been reset to default on all 13.0 branches, so if there was a specific config for your repo, it needs to be reapplied manually as the module are migrated.Let us know of any issue / question.Enjoy!-sbiOn Tue, Oct 8, 2019 at 9:56 PM Maxime Chambreuil <mchambreuil@opensourceintegrators.com> wrote:+1
MAXIME CHAMBREUIL
PROJECT MANAGER/CONSULTANT
O: 1.855.877.2377 EXT. 710
M: 602.427.5632
E: MChambreuil@OpenSourcelntegrators.comP.O. BOX 940, HIGLEY, AZ 85236
On Tue, Oct 8, 2019 at 12:52 PM Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com> wrote:+1Le lun. 7 oct. 2019 à 18:12, Bruno Joliveau <bruno.joliveau@numigi.com> a écrit :+1 from "Numigiens"Have a good day from Canada!
Bruno Joliveau - Architecte applications - PrésidentNUMIGI SOLUTIONS INC.(514) 317-7944Longueuil, Québec, CanadaLe lun. 7 oct. 2019 à 06:56, Stéphane Bidoul <stephane.bidoul@acsone.eu> a écrit :Dear contributors,Following a recent conversation on twitter, and further talks during #OCAdays, there seems to be a wide interest for using Black [1] as a code formatter for OCA code.This post explains the proposed approach to implement it in OCA, as well as several improvements to code linting tools.In a nutshell, Black is a python code formatter that quickly gained traction in the Python community in the last couple of years. It formats the code for you with a predefined set of rules and almost no options so as to free your mind for more important matters.At #OCAdays, we discussed on how to put it in practice, and it was proposed to take the opportunity of this change to introduce pre-commit [2] as the linting framework for OCA in the 13.0 branches.TL;DR: If you are not interested in the nitty gritty details, the only change you will need to remember compared to your current workflow is:
- run Black before committing your code on the 13.0 branches
- sort imports (stdlib, odoo, odoo.addons, local imports)
- To save time, install pre-commit and run pre-commit install after cloning an OCA repository on the 13.0 branch. Linting, running black and sorting imports will be done automatically for you when you commit. You can also run it manually with 'pre-commit run --all-files'.
If you are interested in practical details and the rationale, read on.pre-commit is a tool that lets contributors easily run lint checks locally in a consistent and reproducible manner. These checks are then run again by Travis to be sure conventions are enforced. In principle this is similar to what we are doing now with MQT LINT_CHECK="1", with the following beneficial differences:
- installation of the linters locally is easier: only one tool needs to be installed on developer's machines: pre-commit, which will then take care of installing all the required linters for you
- you then run "pre-commit install" after cloning a repository
- lint checks are then run automatically when creating a commit locally so you can detect errors much earlier, without having to wait for Travis to detect them for you
- some linters (such as Black, and the import sorter) fix the code for you, so you immediately have the diff available with all fixes to commit
- all configurations are stored locally in the repository using default configuration files (.pylintrc, .flake8, etc); this means your favorite IDE will pick them up automatically to give you assistance in detecting and fixing errors
- a wide variety of pre-commit plugins exist, which means we can easily benefit from them and progressively add more in the future
The proposed configuration includes the following linters:
- black, with default options (to facilitate usage)
- auto fix trailing whitespace
- auto fix newline at end of files
- detect debug statements
- flake8 with same options as before (except line length which is now the 88 black default)
- pyupgrade, to encourage python 3 idioms
- pylint with mandatory checks (with some more mandatory checks than before, for v13 only)
- pylint with all checks (optional + mandatory), not failing
- isort to automatically sort imports (except in __init__.py where import order might be significant)
- run eslint as a pre-commit hook, with the same configuration as pylint-odoo except that all checks are warnings. This is the same as what pylint-odoo does (javascript checks are not blocking).
You can see an example configuration in the storage project [3], the queue project [4] as well as partner-contact [5]. Look for the following files: .pre-commit-config.yaml, .flake8, .pylintrc, .eslintrc. Also look at the updated .travis.yml to see how pre-commit is run. To try it out,
- checkout these branches
- run 'pre-commit install'
- start committing lint failures to see the effect.
If you have suggestions to make on the linter configurations, you can make them on this MQT PR: https://github.com/OCA/maintainer-quality-tools/pull/613/filesIn practice, if there are no objections, the plan is to setup this configuration on all 13.0 branches this week, while there are not too many v13 modules merged. To do this, I will push all linter configuration files to 13.0 branches, as well as resetting the travis configuration to the default.When the configurations will need to evolve later, the maintenance of these configuration files will become a bot task. As before, there will be no possibility to configure linting rules per repo.Looking forward to reading your feedback.Best regards,-sbi_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
by dar - 05:41 - 14 Oct 2019
Reference
-
Linting for 13.0 branches (using black and pre-commit)
Dear contributors,Following a recent conversation on twitter, and further talks during #OCAdays, there seems to be a wide interest for using Black [1] as a code formatter for OCA code.This post explains the proposed approach to implement it in OCA, as well as several improvements to code linting tools.In a nutshell, Black is a python code formatter that quickly gained traction in the Python community in the last couple of years. It formats the code for you with a predefined set of rules and almost no options so as to free your mind for more important matters.At #OCAdays, we discussed on how to put it in practice, and it was proposed to take the opportunity of this change to introduce pre-commit [2] as the linting framework for OCA in the 13.0 branches.TL;DR: If you are not interested in the nitty gritty details, the only change you will need to remember compared to your current workflow is:- run Black before committing your code on the 13.0 branches
- sort imports (stdlib, odoo, odoo.addons, local imports)
- To save time, install pre-commit and run pre-commit install after cloning an OCA repository on the 13.0 branch. Linting, running black and sorting imports will be done automatically for you when you commit. You can also run it manually with 'pre-commit run --all-files'.
If you are interested in practical details and the rationale, read on.pre-commit is a tool that lets contributors easily run lint checks locally in a consistent and reproducible manner. These checks are then run again by Travis to be sure conventions are enforced. In principle this is similar to what we are doing now with MQT LINT_CHECK="1", with the following beneficial differences:- installation of the linters locally is easier: only one tool needs to be installed on developer's machines: pre-commit, which will then take care of installing all the required linters for you
- you then run "pre-commit install" after cloning a repository
- lint checks are then run automatically when creating a commit locally so you can detect errors much earlier, without having to wait for Travis to detect them for you
- some linters (such as Black, and the import sorter) fix the code for you, so you immediately have the diff available with all fixes to commit
- all configurations are stored locally in the repository using default configuration files (.pylintrc, .flake8, etc); this means your favorite IDE will pick them up automatically to give you assistance in detecting and fixing errors
- a wide variety of pre-commit plugins exist, which means we can easily benefit from them and progressively add more in the future
The proposed configuration includes the following linters:- black, with default options (to facilitate usage)
- auto fix trailing whitespace
- auto fix newline at end of files
- detect debug statements
- flake8 with same options as before (except line length which is now the 88 black default)
- pyupgrade, to encourage python 3 idioms
- pylint with mandatory checks (with some more mandatory checks than before, for v13 only)
- pylint with all checks (optional + mandatory), not failing
- isort to automatically sort imports (except in __init__.py where import order might be significant)
- run eslint as a pre-commit hook, with the same configuration as pylint-odoo except that all checks are warnings. This is the same as what pylint-odoo does (javascript checks are not blocking).
You can see an example configuration in the storage project [3], the queue project [4] as well as partner-contact [5]. Look for the following files: .pre-commit-config.yaml, .flake8, .pylintrc, .eslintrc. Also look at the updated .travis.yml to see how pre-commit is run. To try it out,- checkout these branches
- run 'pre-commit install'
- start committing lint failures to see the effect.
If you have suggestions to make on the linter configurations, you can make them on this MQT PR: https://github.com/OCA/maintainer-quality-tools/pull/613/filesIn practice, if there are no objections, the plan is to setup this configuration on all 13.0 branches this week, while there are not too many v13 modules merged. To do this, I will push all linter configuration files to 13.0 branches, as well as resetting the travis configuration to the default.When the configurations will need to evolve later, the maintenance of these configuration files will become a bot task. As before, there will be no possibility to configure linting rules per repo.Looking forward to reading your feedback.Best regards,-sbi
by Stéphane Bidoul - 12:56 - 7 Oct 2019




