Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds black and pre-commit hooks (#239)
* Moved /ewatercycle to /src/ewatercycle + adjust config to match Refs #228 * Add black to dev deps Replaces yapf as formatter * Configure black to also format notebooks * Added black and friends as pre-commit hooks and to ci * Files changes by `pre-commit run --all-files` command * Use nbqa-black to format notebooks instead of black As black replaces " with ', which makes invalid JSON * On release run pre-commit on all files * Disable flake8 until its errors are fixed * Added flake8 plugins Selection from https://towardsdatascience.com/static-code-analysis-for-python-bdce10b8d287 * Make isort, pylint and flake8 compatible with black See https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html * Use tabs in makefile * Replace prospector with pre-commit * Prefer `@pytest.fixture` over `@pytest.fixture()` * Added pylint and bunch of flake8 plugins to pre commit config Using YAML anchor + alias for nb * Move config from arg to file + pytest-fixture config inverted * Disable pylint and fix flake8 errors first * Ignore docstring checks in tests/ + Move google doc style to where pydocstyle expects it * Fix flake8 errors * Reduce flake8 warnings * Fix doc generator + Fix bunch of lint warnings * More of the same * Fixing lint errors in grdc Fixes #241 * Make flake8 just print errors instead of dying * Fix line lengths in ewatercycle.models * Fix line lengths in config * Fix line lengths in ewatercycle.parameter_sets * fix line lengths in ewatercycle.forcing * Fix remaining line lengths in ewatercycle package * noqa instead of pylint-specific * Fix line lengths in tests * fix error message * Force showing of warnings of nbqa-flake8 * Update .pre-commit-config.yaml Co-authored-by: Peter Kalverla <peter.kalverla@gmx.com> Co-authored-by: Peter Kalverla <peter.kalverla@gmx.com>
- Loading branch information
1 parent
6a4fe28
commit c794ef7
Showing
69 changed files
with
2,306 additions
and
1,964 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,6 @@ indent_size = 2 | |
|
||
[*.{md,Rmd}] | ||
trim_trailing_whitespace = false | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.4.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-ast | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: debug-statements | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
args: [--markdown-linebreak-ext=md] | ||
- repo: https://github.com/adrienverge/yamllint | ||
rev: "v1.26.0" | ||
hooks: | ||
- id: yamllint | ||
- repo: https://github.com/asottile/setup-cfg-fmt | ||
rev: v1.17.0 | ||
hooks: | ||
- id: setup-cfg-fmt | ||
- repo: https://github.com/psf/black | ||
rev: 21.7b0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/PyCQA/isort | ||
rev: "5.9.3" | ||
hooks: | ||
- id: isort | ||
# TODO renable when errors are fixed/ignored | ||
# - repo: https://github.com/pycqa/pylint | ||
# rev: "v2.9.6" | ||
# hooks: | ||
# - id: pylint | ||
# TODO renable when errors are fixed/ignored | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: "3.9.2" | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
&fd [ | ||
flake8-annotations-complexity, | ||
flake8-bandit, | ||
flake8-blind-except, | ||
flake8-bugbear, | ||
flake8-builtins, | ||
flake8-cognitive-complexity, | ||
flake8-comprehensions, | ||
flake8-docstrings, | ||
flake8-eradicate, | ||
flake8-executable, | ||
flake8-expression-complexity, | ||
flake8-if-expr, | ||
flake8-implicit-str-concat, | ||
flake8-logging-format, | ||
flake8-pathlib, | ||
flake8-print, | ||
flake8-pytest, | ||
flake8-pytest-style, | ||
# flake8-quotes, # conflicts with blacks double quote preference | ||
flake8-raise, | ||
flake8-return, | ||
flake8-typing-imports, | ||
flake8-variables-names, | ||
flake8==3.9.2, | ||
pandas-vet, | ||
pep8-naming, | ||
# wemake-python-styleguide, # conflicts with black | ||
yesqa, | ||
] | ||
verbose: true | ||
args: &fa [--statistics, --exit-zero] | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v0.910 | ||
hooks: | ||
- id: mypy | ||
additional_dependencies: [types-python-dateutil] | ||
- repo: https://github.com/nbQA-dev/nbQA | ||
rev: 1.1.0 | ||
hooks: | ||
- id: nbqa-black | ||
# Match version of black used for .py and .ipynb | ||
additional_dependencies: [black==21.7b0] | ||
- id: nbqa-isort | ||
additional_dependencies: [isort==5.9.3] | ||
- id: nbqa-mypy | ||
additional_dependencies: [mypy==0.910] | ||
# TODO renable when errors are fixed/ignored | ||
- id: nbqa-flake8 | ||
additional_dependencies: *fd | ||
args: *fa | ||
verbose: true | ||
# TODO renable when errors are fixed/ignored | ||
# - id: nbqa-pylint | ||
# additional_dependencies: [pylint==2.9.6] | ||
- repo: https://github.com/regebro/pyroma | ||
rev: "3.2" | ||
hooks: | ||
- id: pyroma |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.