-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds black and pre-commit hooks #239
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
03bf430
Moved /ewatercycle to /src/ewatercycle + adjust config to match
sverhoeven 910c075
Add black to dev deps
sverhoeven 9607f3e
Configure black to also format notebooks
sverhoeven bd3d472
Added black and friends as pre-commit hooks and to ci
sverhoeven d9a6fa5
Files changes by `pre-commit run --all-files` command
sverhoeven b3f7013
Use nbqa-black to format notebooks instead of black
sverhoeven 565eb19
On release run pre-commit on all files
sverhoeven ca821b6
Disable flake8 until its errors are fixed
sverhoeven c6b42e7
Merge remote-tracking branch 'origin/main' into 111-black
sverhoeven 22adbe7
Added flake8 plugins
sverhoeven 107afa5
Make isort, pylint and flake8 compatible with black
sverhoeven 9141a5d
Use tabs in makefile
sverhoeven ba8cba8
Replace prospector with pre-commit
sverhoeven 7a4bab4
Prefer `@pytest.fixture` over `@pytest.fixture()`
sverhoeven 7f27ade
Added pylint and bunch of flake8 plugins to pre commit config
sverhoeven 33cafd1
Move config from arg to file + pytest-fixture config inverted
sverhoeven 13d2d42
Disable pylint and fix flake8 errors first
sverhoeven c74b2f5
Ignore docstring checks in tests/ + Move google doc style to where py…
sverhoeven 35afd99
Fix flake8 errors
sverhoeven 096ea90
Reduce flake8 warnings
sverhoeven 59abbe3
Fix doc generator + Fix bunch of lint warnings
sverhoeven 05938c8
More of the same
sverhoeven a69a5c9
Fixing lint errors in grdc
sverhoeven 6695108
Make flake8 just print errors instead of dying
sverhoeven ddbd76e
Fix line lengths in ewatercycle.models
Peter9192 f5b3fc6
Fix line lengths in config
Peter9192 644e14d
Fix line lengths in ewatercycle.parameter_sets
Peter9192 6786f7a
fix line lengths in ewatercycle.forcing
Peter9192 e6b91cf
Fix remaining line lengths in ewatercycle package
Peter9192 0f5bf78
noqa instead of pylint-specific
Peter9192 8e47e24
Fix line lengths in tests
Peter9192 b0f5f8d
fix error message
Peter9192 a6f0436
Force showing of warnings of nbqa-flake8
sverhoeven 04723c5
Update .pre-commit-config.yaml
sverhoeven 70f957d
Merge branch '111-black' of github.com:eWaterCycle/ewatercycle into 1…
sverhoeven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be that the notebooks (in docs) are not picked up by these checks?
This check passes on
pre-commit run --all-files
for me, but if I dopip install nbqa
and thennbqa flake8 docs/*.ipynb
I get a list of issues.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue is
, I'm not sure what it's meant to do here, but if you remove it then
pre-commit run nbqa-flake8 --all-files
will fail tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
flake8
hook is verbose by default whilenbqa-flake8
was not, I forced it to be verbose so now warnings show up.The
*fa
is a YAML alias of YAML anchor defined inflake8
hook with@fa
so I do not have to repeat the list of flake8 plugins.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know you could do that, thanks! This'll be useful in other projects