Keep pre-commit inline with hacking and fix whitespace

The flake8 hook for pre-commit installs its own flake8 which is
not what hacking is pinned to. This results in a bunch of errors.
By doing a local hook we can cause these to be the same.

There are flake8 exclusions in tox.ini that need to be used
in pre-commit. Also we should exclude svg files from the whitespace
modifications, because who cares.

Once those are fixed, running pre-commit -a fixes some whitespace
issues. While the normal use isn't to run -a - if someone does make
a patch that touches any of these they'll get erroneous unrelated
errors compared to their lower work - so fix all of the existing
issues, which are mostly space-at-end-of-line issues it seems.

Change-Id: I78e753492e99c03b30a0a691db3bd75ee3d289c9
This commit is contained in:
Monty Taylor 2019-08-01 10:44:08 -04:00 committed by Stephen Finucane
parent 2e7a0088c2
commit e7cc5efd20
12 changed files with 81 additions and 70 deletions

View File

@ -6,16 +6,27 @@ repos:
- id: trailing-whitespace - id: trailing-whitespace
- id: mixed-line-ending - id: mixed-line-ending
args: ['--fix', 'lf'] args: ['--fix', 'lf']
exclude: '.*\.(svg)$'
- id: check-byte-order-marker - id: check-byte-order-marker
- id: check-executables-have-shebangs - id: check-executables-have-shebangs
- id: check-merge-conflict - id: check-merge-conflict
- id: debug-statements - id: debug-statements
- id: flake8 # nova/cmd/manage.py imports pdb on purpose.
additional_dependencies: exclude: 'nova/cmd/manage.py'
- hacking>=1.1.0,<1.2.0
- id: check-yaml - id: check-yaml
files: .*\.(yaml|yml)$ files: .*\.(yaml|yml)$
- repo: https://github.com/Lucas-C/pre-commit-hooks - repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.7 rev: v1.1.7
hooks: hooks:
- id: remove-tabs - id: remove-tabs
exclude: '.*\.(svg)$'
- repo: local
hooks:
- id: flake8
name: flake8
additional_dependencies:
- hacking>=1.1.0,<1.2.0
language: python
entry: flake8
files: '^.*\.py$'
exclude: '^(doc|releasenotes|tools)/.*$'

View File

@ -28,9 +28,9 @@ in the long-running code path. The sleep call will trigger a context switch
if there are pending threads, and using an argument of 0 will avoid introducing if there are pending threads, and using an argument of 0 will avoid introducing
delays in the case that there is only a single green thread:: delays in the case that there is only a single green thread::
from eventlet import greenthread from eventlet import greenthread
... ...
greenthread.sleep(0) greenthread.sleep(0)
In current code, time.sleep(0) does the same thing as greenthread.sleep(0) if In current code, time.sleep(0) does the same thing as greenthread.sleep(0) if
time module is patched through eventlet.monkey_patch(). To be explicit, we recommend time module is patched through eventlet.monkey_patch(). To be explicit, we recommend

View File

@ -13,25 +13,25 @@ _get_nova_manage_subopts () {
_nova_manage() _nova_manage()
{ {
local cur prev subopts local cur prev subopts
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "x$_nova_manage_opts" == "x" ] ; then if [ "x$_nova_manage_opts" == "x" ] ; then
_nova_manage_opts="`nova-manage bash-completion 2>/dev/null`" _nova_manage_opts="`nova-manage bash-completion 2>/dev/null`"
_nova_manage_opts_exp="`echo $_nova_manage_opts | sed -e "s/\s/|/g"`" _nova_manage_opts_exp="`echo $_nova_manage_opts | sed -e "s/\s/|/g"`"
fi fi
if [[ " `echo $_nova_manage_opts` " =~ " $prev " ]] ; then if [[ " `echo $_nova_manage_opts` " =~ " $prev " ]] ; then
if [ "x$(_get_nova_manage_subopts "$prev")" == "x" ] ; then if [ "x$(_get_nova_manage_subopts "$prev")" == "x" ] ; then
subopts="`nova-manage bash-completion $prev 2>/dev/null`" subopts="`nova-manage bash-completion $prev 2>/dev/null`"
_set_nova_manage_subopts "$prev" "$subopts" _set_nova_manage_subopts "$prev" "$subopts"
fi fi
COMPREPLY=($(compgen -W "$(_get_nova_manage_subopts "$prev")" -- ${cur})) COMPREPLY=($(compgen -W "$(_get_nova_manage_subopts "$prev")" -- ${cur}))
elif [[ ! " ${COMP_WORDS[@]} " =~ " "($_nova_manage_opts_exp)" " ]] ; then elif [[ ! " ${COMP_WORDS[@]} " =~ " "($_nova_manage_opts_exp)" " ]] ; then
COMPREPLY=($(compgen -W "${_nova_manage_opts}" -- ${cur})) COMPREPLY=($(compgen -W "${_nova_manage_opts}" -- ${cur}))
fi fi
return 0 return 0
} }
complete -F _nova_manage nova-manage complete -F _nova_manage nova-manage