Skip to content

Commit eaec72e

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "pre-commit: Migrate bandit to ruff"
2 parents f637846 + fc6852c commit eaec72e

15 files changed

Lines changed: 38 additions & 37 deletions

File tree

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ repos:
2525
- id: ruff
2626
args: ['--fix']
2727
- id: ruff-format
28-
- repo: https://github.com/PyCQA/bandit
29-
rev: 1.7.9
30-
hooks:
31-
- id: bandit
32-
args: ['-x', 'tests']
3328
- repo: https://opendev.org/openstack/hacking
3429
rev: 7.0.0
3530
hooks:

openstackclient/common/clientmanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _fallback_load_auth_plugin(self, e):
101101
# expect, delete fake token and endpoint, then try to
102102
# load auth plugin again with user specified options.
103103
# We know it looks ugly, but it's necessary.
104-
if self._cli_options.config['auth']['token'] == 'x':
104+
if self._cli_options.config['auth']['token'] == 'x': # noqa: S105
105105
# restore original auth_type
106106
self._cli_options.config['auth_type'] = self._original_auth_type
107107
del self._cli_options.config['auth']['token']

openstackclient/common/module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def take_action(self, parsed_args):
111111
data[k] = mods[k].version.__version__
112112
else:
113113
data[k] = mods[k].__version__
114-
except Exception:
114+
except Exception: # noqa: S110
115115
# Catch all exceptions, just skip it
116-
pass # nosec: B110
116+
pass
117117

118118
return zip(*sorted(data.items()))

openstackclient/compute/v2/server.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,10 +2912,10 @@ def take_action(self, parsed_args):
29122912
for image_id in image_ids:
29132913
try:
29142914
images[image_id] = image_client.get_image(image_id)
2915-
except Exception:
2915+
except Exception: # noqa: S110
29162916
# retrieving image names is not crucial, so we swallow
29172917
# any exceptions
2918-
pass # nosec: B110
2918+
pass
29192919
else:
29202920
try:
29212921
# some deployments can have *loads* of images so we only
@@ -2933,10 +2933,10 @@ def take_action(self, parsed_args):
29332933
)
29342934
for i in images_list:
29352935
images[i.id] = i
2936-
except Exception:
2936+
except Exception: # noqa: S110
29372937
# retrieving image names is not crucial, so we swallow any
29382938
# exceptions
2939-
pass # nosec: B110
2939+
pass
29402940

29412941
# create a dict that maps flavor_id to flavor object, which is used
29422942
# to display the "Flavor Name" column. Note that 'flavor.id' is not
@@ -2952,19 +2952,19 @@ def take_action(self, parsed_args):
29522952
flavors[f_id] = compute_client.find_flavor(
29532953
f_id, ignore_missing=False
29542954
)
2955-
except Exception:
2955+
except Exception: # noqa: S110
29562956
# retrieving flavor names is not crucial, so we swallow
29572957
# any exceptions
2958-
pass # nosec: B110
2958+
pass
29592959
else:
29602960
try:
29612961
flavors_list = compute_client.flavors(is_public=None)
29622962
for i in flavors_list:
29632963
flavors[i.id] = i
2964-
except Exception:
2964+
except Exception: # noqa: S110
29652965
# retrieving flavor names is not crucial, so we swallow any
29662966
# exceptions
2967-
pass # nosec: B110
2967+
pass
29682968

29692969
# Populate image_name, image_id, flavor_name and flavor_id attributes
29702970
# of server objects so that we can display those columns.
@@ -4869,7 +4869,7 @@ def take_action(self, parsed_args):
48694869
LOG.debug(f"ssh command: {cmd}")
48704870
# we intentionally pass through user-provided arguments and run this in
48714871
# the user's shell
4872-
os.system(cmd) # nosec: B605
4872+
os.system(cmd) # noqa: S605
48734873

48744874

48754875
class StartServer(command.Command):

openstackclient/compute/v2/usage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ def _format_project(project):
180180
try:
181181
for p in self.app.client_manager.identity.projects.list():
182182
project_cache[p.id] = p
183-
except Exception:
183+
except Exception: # noqa: S110
184184
# Just forget it if there's any trouble
185-
pass # nosec: B110
185+
pass
186186

187187
if parsed_args.formatter == 'table' and len(usage_list) > 0:
188188
self.app.stdout.write(

openstackclient/identity/v2_0/user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ def take_action(self, parsed_args):
250250
try:
251251
for p in identity_client.tenants.list():
252252
project_cache[p.id] = p
253-
except Exception:
253+
except Exception: # noqa: S110
254254
# Just forget it if there's any trouble
255-
pass # nosec: B110
255+
pass
256256
formatters['tenantId'] = functools.partial(
257257
ProjectColumn, project_cache=project_cache
258258
)

openstackclient/volume/v1/volume.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ def take_action(self, parsed_args):
422422
compute_client = self.app.client_manager.sdk_connection.compute
423423
for s in compute_client.servers():
424424
server_cache[s.id] = s
425-
except Exception:
425+
except Exception: # noqa: S110
426426
# Just forget it if there's any trouble
427-
pass # nosec: B110
427+
pass
428428
AttachmentsColumnWithCache = functools.partial(
429429
AttachmentsColumn, server_cache=server_cache
430430
)

openstackclient/volume/v1/volume_backup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ def take_action(self, parsed_args):
215215
try:
216216
for s in volume_client.volumes.list():
217217
volume_cache[s.id] = s
218-
except Exception:
218+
except Exception: # noqa: S110
219219
# Just forget it if there's any trouble
220-
pass # nosec: B110
220+
pass
221221
VolumeIdColumnWithCache = functools.partial(
222222
VolumeIdColumn, volume_cache=volume_cache
223223
)

openstackclient/volume/v1/volume_snapshot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ def take_action(self, parsed_args):
242242
try:
243243
for s in volume_client.volumes.list():
244244
volume_cache[s.id] = s
245-
except Exception:
245+
except Exception: # noqa: S110
246246
# Just forget it if there's any trouble
247-
pass # nosec: B110
247+
pass
248248
VolumeIdColumnWithCache = functools.partial(
249249
VolumeIdColumn, volume_cache=volume_cache
250250
)

openstackclient/volume/v2/volume.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,9 @@ def take_action(self, parsed_args):
511511
compute_client = self.app.client_manager.sdk_connection.compute
512512
for s in compute_client.servers():
513513
server_cache[s.id] = s
514-
except sdk_exceptions.SDKException:
514+
except sdk_exceptions.SDKException: # noqa: S110
515515
# Just forget it if there's any trouble
516-
pass # nosec: B110
516+
pass
517517
AttachmentsColumnWithCache = functools.partial(
518518
AttachmentsColumn, server_cache=server_cache
519519
)

0 commit comments

Comments
 (0)