-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add pre commit configuration (take 2) #3999
Changes from all commits
fd76f34
0536aeb
77ba10e
9151b27
e477cf2
3671a58
8606c69
4a5b5ba
0826865
5e1468b
8901672
4b5cb91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
max-line-length = 79 | ||
select = B,C,E,F,W,T4,B9,B950 | ||
ignore = E402, W503, W504 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ jobs: | |
|
||
- name: Style | ||
run: | | ||
pycodestyle | ||
flake8 | ||
etc/bin/shellchecker | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[settings] | ||
multi_line_output=3 | ||
include_trailing_comma=true | ||
force_grid_wrap=0 | ||
use_parentheses=true | ||
ensure_newline_before_comments=true | ||
line_length=79 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/timothycrosley/isort | ||
rev: 5.6.4 | ||
hooks: | ||
- id: isort | ||
files: .*.py | ||
- repo: https://github.com/psf/black | ||
rev: 20.8b1 | ||
hooks: | ||
- id: black | ||
args: ["--line-length", "79", "-t", "py37"] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: check-ast | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think we need this (slow) one if we are using Also I think pytest would bail anyway? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds convincing. Would you agree @sgaist ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, there might also be other hooks that also uses the AST for their work, so it's one that can be dropped in this case. |
||
- id: check-case-conflict | ||
- id: trailing-whitespace | ||
hjoliver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- id: end-of-file-fixer | ||
hjoliver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- id: debug-statements | ||
- id: check-added-large-files | ||
- id: check-docstring-first | ||
- id: check-yaml | ||
exclude: conda/meta.yaml | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 3.8.4 | ||
hooks: | ||
- id: flake8 | ||
oliver-sanders marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- repo: https://github.com/PyCQA/bandit | ||
rev: 1.6.2 | ||
hooks: | ||
- id: bandit |
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.
This overrides existing
flake8
config present intox.ini
.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.
Yes, that's why the fast tests were failing on the original branch, until I added our usual warning ignore settings here instead of the ones @sgaist used.
As per my comments above,
pycodestyle
(andflake8
, which wrapspycodestyle
) ignores thetox.ini
config on one of my dev platforms, because of inline comments in the file, even though thepycodestyle
version claims to be the same.However, now that I understand the cause I could move those comments, and we could drop this new config. Is there any reason at all to have both?
Annoyingly, it seems
tox.ini
needs duplicate pycodestyle settings, under[pycodestyle]
and[flake8]
sections, unless you never runpycodestyle
alone. Also, flake8 ignores W503 and W504 by default (but not if you explicitly ignore anything else).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.
There's a bit of complexity with all the possible configuration files that can be used. There's also the pyproject that might be used but may not be supported by all the tools.
I have a project which has flake8 in
tox.ini
, bandit in its own file because they were (might still) not supporting thepyproject.toml
nortox.ini
, and the rest is inpyproject.toml
. I like the idea of having a maximum of configurations in a single file but that is rather up to the taste of the maintainer(s).