Skip to content

Commit ad0063a

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Use pre-commit for lint jobs"
2 parents 3b9e959 + d54efa9 commit ad0063a

File tree

7 files changed

+62
-46
lines changed

7 files changed

+62
-46
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
---
2-
default_language_version:
3-
# force all unspecified python hooks to run python3
4-
python: python3
52
repos:
63
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.1.0
4+
rev: v5.0.0
85
hooks:
96
- id: trailing-whitespace
107
- id: mixed-line-ending
@@ -16,17 +13,18 @@ repos:
1613
- id: check-yaml
1714
files: .*\.(yaml|yml)$
1815
- repo: https://github.com/Lucas-C/pre-commit-hooks
19-
rev: v1.1.13
16+
rev: v1.5.5
2017
hooks:
2118
- id: remove-tabs
2219
exclude: '.*\.(svg)$'
23-
- repo: local
20+
- repo: https://github.com/PyCQA/bandit
21+
rev: 1.8.5
2422
hooks:
25-
- id: flake8
26-
name: flake8
27-
additional_dependencies:
28-
- hacking>=6.1.0,<6.2.0
29-
language: python
30-
entry: flake8
31-
files: '^.*\.py$'
23+
- id: bandit
24+
exclude: '^novaclient/tests/.*$'
25+
- repo: https://opendev.org/openstack/hacking
26+
rev: 7.0.0
27+
hooks:
28+
- id: hacking
29+
additional_dependencies: []
3230
exclude: '^(doc|releasenotes|tools)/.*$'

novaclient/crypto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# under the License.
1515

1616
import base64
17-
import subprocess
17+
import subprocess # nosec: B404
1818

1919

2020
class DecryptionFailure(Exception):
@@ -30,7 +30,7 @@ def decrypt_password(private_key, password):
3030
cmd = ['openssl', 'rsautl', '-decrypt', '-inkey', private_key]
3131
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
3232
stdout=subprocess.PIPE,
33-
stderr=subprocess.PIPE)
33+
stderr=subprocess.PIPE) # nosec: B603
3434
out, err = proc.communicate(unencoded)
3535
proc.stdin.close()
3636
if proc.returncode:

novaclient/v2/shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4208,7 +4208,7 @@ def do_ssh(cs, args):
42084208
cmd = "ssh -%d -p%d %s %s@%s %s" % (version, args.port, identity,
42094209
args.login, ip_address, args.extra)
42104210
logger.debug("Executing cmd '%s'", cmd)
4211-
os.system(cmd)
4211+
os.system(cmd) # nosec: B605
42124212

42134213

42144214
# NOTE(mriedem): In the 2.50 microversion, the os-quota-class-sets API

releasenotes/notes/remove_api_v_1_1-88b3f18ce1423b46.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
upgrade:
33
- remove version 1.1 API support as we only support v2 and v2.1
44
API in nova side now.
5-

test-requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
hacking>=6.1.0,<6.2.0 # Apache-2.0
2-
bandit>=1.1.0 # Apache-2.0
31
coverage>=4.4.1 # Apache-2.0
42
ddt>=1.0.1 # MIT
53
fixtures>=3.0.0 # Apache-2.0/BSD

tools/nova.bash_completion

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ _nova_flags="" # lazy init
33
_nova_opts_exp="" # lazy init
44
_nova()
55
{
6-
local cur prev nbc cflags
7-
COMPREPLY=()
8-
cur="${COMP_WORDS[COMP_CWORD]}"
9-
prev="${COMP_WORDS[COMP_CWORD-1]}"
6+
local cur prev nbc cflags
7+
COMPREPLY=()
8+
cur="${COMP_WORDS[COMP_CWORD]}"
9+
prev="${COMP_WORDS[COMP_CWORD-1]}"
1010

11-
if [ "x$_nova_opts" == "x" ] ; then
12-
nbc="`nova bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`"
13-
_nova_opts="`echo "$nbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`"
14-
_nova_flags="`echo " $nbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`"
15-
_nova_opts_exp="`echo "$_nova_opts" | tr ' ' '|'`"
16-
fi
11+
if [ "x$_nova_opts" == "x" ] ; then
12+
nbc="`nova bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`"
13+
_nova_opts="`echo "$nbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`"
14+
_nova_flags="`echo " $nbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`"
15+
_nova_opts_exp="`echo "$_nova_opts" | tr ' ' '|'`"
16+
fi
1717

18-
if [[ " ${COMP_WORDS[@]} " =~ " "($_nova_opts_exp)" " && "$prev" != "help" ]] ; then
19-
COMPLETION_CACHE=~/.novaclient/*/*-cache
20-
cflags="$_nova_flags "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ')
21-
COMPREPLY=($(compgen -W "${cflags}" -- ${cur}))
22-
else
23-
COMPREPLY=($(compgen -W "${_nova_opts}" -- ${cur}))
24-
fi
25-
return 0
18+
if [[ " ${COMP_WORDS[@]} " =~ " "($_nova_opts_exp)" " && "$prev" != "help" ]] ; then
19+
COMPLETION_CACHE=~/.novaclient/*/*-cache
20+
cflags="$_nova_flags "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ')
21+
COMPREPLY=($(compgen -W "${cflags}" -- ${cur}))
22+
else
23+
COMPREPLY=($(compgen -W "${_nova_opts}" -- ${cur}))
24+
fi
25+
return 0
2626
}
2727
complete -F _nova nova

tox.ini

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
[tox]
22
envlist = py3,pep8,docs
3-
minversion = 3.18.0
4-
ignore_basepython_conflict = true
3+
minversion = 4.6.0
54

65
[testenv]
7-
basepython = python3
6+
description =
7+
Run unit tests.
88
usedevelop = true
9-
# tox is silly... these need to be separated by a newline....
109
allowlist_externals =
1110
find
1211
rm
@@ -23,10 +22,20 @@ commands =
2322
stestr run {posargs}
2423

2524
[testenv:pep8]
26-
commands = flake8 {posargs}
25+
description =
26+
Run style checks.
27+
deps =
28+
pre-commit
29+
commands =
30+
pre-commit run --all-files --show-diff-on-failure
2731

2832
[testenv:bandit]
29-
commands = bandit -r novaclient -n5 -x tests
33+
description =
34+
Run security checks.
35+
deps =
36+
pre-commit
37+
commands =
38+
pre-commit run --all-files --show-diff-on-failure bandit
3039

3140
[testenv:venv]
3241
deps =
@@ -37,6 +46,8 @@ deps =
3746
commands = {posargs}
3847

3948
[testenv:docs]
49+
description =
50+
Build documentation in HTML format.
4051
deps =
4152
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
4253
-r{toxinidir}/doc/requirements.txt
@@ -47,26 +58,35 @@ commands =
4758
whereto doc/build/html/.htaccess doc/test/redirect-tests.txt
4859

4960
[testenv:pdf-docs]
61+
description =
62+
Build documentation in PDF format.
5063
deps = {[testenv:docs]deps}
5164
commands =
5265
rm -rf doc/build/pdf
5366
sphinx-build -W -b latex doc/source doc/build/pdf
5467
make -C doc/build/pdf
5568

5669
[testenv:releasenotes]
70+
description =
71+
Build release notes.
5772
deps =
5873
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
5974
-r{toxinidir}/doc/requirements.txt
6075
commands =
6176
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
6277

6378
[testenv:functional{,-py39,-py310,-py311,-py312}]
64-
passenv = OS_*
79+
description =
80+
Run functional tests.
81+
passenv =
82+
OS_*
6583
commands =
6684
stestr --test-path=./novaclient/tests/functional run --concurrency=1 {posargs}
6785
python novaclient/tests/functional/hooks/check_resources.py
6886

6987
[testenv:cover]
88+
description =
89+
Run unit tests and print coverage information.
7090
setenv =
7191
PYTHON=coverage run --source novaclient --parallel-mode
7292
commands =
@@ -93,11 +113,12 @@ exclude=.venv,.git,.tox,dist,*lib/python*,*egg,build,doc/source/conf.py,releasen
93113
import_exceptions = novaclient.i18n
94114

95115
[testenv:bindep]
116+
description =
117+
Check for installed binary dependencies.
96118
# Do not install any requirements. We want this to be fast and work even if
97119
# system dependencies are missing, since it's used to tell you what system
98120
# dependencies are missing! This also means that bindep must be installed
99121
# separately, outside of the requirements files.
100122
deps = bindep
101-
skipsdist=True
102-
usedevelop=False
123+
skip_install = true
103124
commands = bindep test

0 commit comments

Comments
 (0)