From b03a220560bd6520c328ee00a6ae6868309b134e Mon Sep 17 00:00:00 2001 From: COUSIN Loic Date: Tue, 13 Dec 2022 16:52:57 +0100 Subject: [PATCH 1/2] pre-commit: add hooks for notebooks --- .pre-commit-config.yaml | 211 +++++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 99 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c709879a78..84b583576d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,110 +17,123 @@ repos: - id: destroyed-symlinks - id: check-symlinks -- repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 - hooks: - - id: rst-backticks - - id: rst-directive-colons - - id: rst-inline-touching-normal + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.9.0 + hooks: + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal -- repo: https://github.com/PyCQA/autoflake - rev: v2.0.0 - hooks: - - id: autoflake - args: [ - --in-place, - --remove-all-unused-imports, - ] + - repo: https://github.com/PyCQA/autoflake + rev: v2.0.0 + hooks: + - id: autoflake + args: [ + --in-place, + --remove-all-unused-imports, + ] -- repo: https://github.com/asottile/reorder_python_imports - rev: v3.9.0 - hooks: - - id: reorder-python-imports - name: reorder python imports in src - files: ^src - args: [ - --application-directories, - src, - --py37-plus, - --add-import, - "from __future__ import annotations", - --replace-import, - "typing=gemseo.utils.python_compatibility:Final" - ] - - id: reorder-python-imports - name: reorder python imports out of src - exclude: ^src - args: [ - --py37-plus, - --add-import, - "from __future__ import annotations", - --replace-import, - "typing=gemseo.utils.python_compatibility:Final" - ] + - repo: https://github.com/asottile/reorder_python_imports + rev: v3.9.0 + hooks: + - id: reorder-python-imports + name: reorder python imports in src + files: ^src + args: [ + --application-directories, + src, + --py37-plus, + --add-import, + "from __future__ import annotations", + --replace-import, + "typing=gemseo.utils.python_compatibility:Final" + ] + - id: reorder-python-imports + name: reorder python imports out of src + exclude: ^src + args: [ + --py37-plus, + --add-import, + "from __future__ import annotations", + --replace-import, + "typing=gemseo.utils.python_compatibility:Final" + ] -- repo: https://github.com/myint/docformatter - rev: v1.5.0 - hooks: - - id: docformatter - args: [ - --in-place, - --wrap-summaries, - "89", - --wrap-descriptions, - "89", - ] + - repo: https://github.com/myint/docformatter + rev: v1.5.0 + hooks: + - id: docformatter + args: [ + --in-place, + --wrap-summaries, + "89", + --wrap-descriptions, + "89", + ] -- repo: https://github.com/asottile/pyupgrade - rev: v3.2.3 - hooks: - - id: pyupgrade - args: [--py37-plus] + - repo: https://github.com/asottile/pyupgrade + rev: v3.2.3 + hooks: + - id: pyupgrade + args: [ --py37-plus ] -- repo: https://github.com/psf/black - rev: 22.10.0 - hooks: - - id: black + - repo: https://github.com/psf/black + rev: 22.10.0 + hooks: + - id: black -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - additional_dependencies: - - flake8-bugbear==22.10.27 - - flake8-docstrings==1.6.0 - - flake8-logging-format==0.9.0 - - flake8-print==5.0.0 - - pep8-naming==0.13.2 + - repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + additional_dependencies: + - flake8-bugbear==22.10.27 + - flake8-docstrings==1.6.0 + - flake8-logging-format==0.9.0 + - flake8-print==5.0.0 + - pep8-naming==0.13.2 -- repo: https://github.com/commitizen-tools/commitizen - rev: v2.37.1 - hooks: - - id: commitizen - stages: [commit-msg] + - repo: https://github.com/commitizen-tools/commitizen + rev: v2.37.1 + hooks: + - id: commitizen + stages: [ commit-msg ] -- repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.3.1 - hooks: - - id: insert-license - name: insert LGPL license - exclude: ^doc_src - files: \.py$ - args: - - --license-filepath - - LICENSES/headers/LGPL-3.0.txt - - id: insert-license - name: insert BSD license - files: ^doc_src/(examples|tutorials).*\.py$ - args: - - --license-filepath - - LICENSES/headers/BSD-0-Clause.txt - - id: insert-license - name: insert CC BY-SA license - files: (\.rst|\.rst\.txt)$ - exclude: ^changelog/fragments - args: - - --license-filepath - - LICENSES/headers/CC-BY-SA-4.0.txt - - --comment-style - - ..| | + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.3.1 + hooks: + - id: insert-license + name: insert LGPL license + exclude: ^doc_src + files: \.py$ + args: + - --license-filepath + - LICENSES/headers/LGPL-3.0.txt + - id: insert-license + name: insert BSD license + files: ^doc_src/(examples|tutorials).*\.py$ + args: + - --license-filepath + - LICENSES/headers/BSD-0-Clause.txt + - id: insert-license + name: insert CC BY-SA license + files: (\.rst|\.rst\.txt)$ + exclude: ^changelog/fragments + args: + - --license-filepath + - LICENSES/headers/CC-BY-SA-4.0.txt + - --comment-style + - ..| | + + - repo: https://github.com/kynan/nbstripout + rev: 0.6.1 + hooks: + - id: nbstripout + + - repo: https://github.com/nbQA-dev/nbQA + rev: 1.5.3 + hooks: + - id: nbqa-black + - id: nbqa-pyupgrade + args: [ "--py37-plus" ] + - id: nbqa-autopep8 -- GitLab From e108912582ba7a8ba064ed710c4a484c8c100b8c Mon Sep 17 00:00:00 2001 From: COUSIN Loic Date: Mon, 19 Dec 2022 09:20:15 +0100 Subject: [PATCH 2/2] pre-commit indentation --- .pre-commit-config.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 84b583576d..8a206067db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,20 +2,20 @@ exclude: ^src/gemseo/third_party repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - exclude: (LICENSES/headers|tests/core/data/factory/.*\.json) - - id: check-yaml - # !reference is specific to gitlab - exclude: .gitlab-ci.yml - - id: check-added-large-files - - id: check-json - - id: check-toml - - id: destroyed-symlinks - - id: check-symlinks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + exclude: (LICENSES/headers|tests/core/data/factory/.*\.json) + - id: check-yaml + # !reference is specific to gitlab + exclude: .gitlab-ci.yml + - id: check-added-large-files + - id: check-json + - id: check-toml + - id: destroyed-symlinks + - id: check-symlinks - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.9.0 -- GitLab