Skip to content

Commit fc6852c

Browse files
committed
pre-commit: Migrate bandit to ruff
The name of the errors change and we need to move things around a little, but it's otherwise a straight swap. Change-Id: I0a19765ebeaa14c0534faa1542165b76ed2bf4e2 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent e60ca0f commit fc6852c

File tree

15 files changed

+38
-37
lines changed

15 files changed

+38
-37
lines changed

.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
@@ -2915,10 +2915,10 @@ def take_action(self, parsed_args):
29152915
for image_id in image_ids:
29162916
try:
29172917
images[image_id] = image_client.get_image(image_id)
2918-
except Exception:
2918+
except Exception: # noqa: S110
29192919
# retrieving image names is not crucial, so we swallow
29202920
# any exceptions
2921-
pass # nosec: B110
2921+
pass
29222922
else:
29232923
try:
29242924
# some deployments can have *loads* of images so we only
@@ -2936,10 +2936,10 @@ def take_action(self, parsed_args):
29362936
)
29372937
for i in images_list:
29382938
images[i.id] = i
2939-
except Exception:
2939+
except Exception: # noqa: S110
29402940
# retrieving image names is not crucial, so we swallow any
29412941
# exceptions
2942-
pass # nosec: B110
2942+
pass
29432943

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

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

48774877

48784878
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)