pre-commit: Migrate from flake8 to ruff
Well, mostly. We still keep our own flake8 hooks and the hacking hooks enabled. Everything else can be handled by ruff. Doing this enables a couple of hacking checks that were previously unaddressed. It also highlights a few cases that flake8 missed. Both are addressed. Change-Id: If81c7055e9ef692425da2789bae18a96d04b104f Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
869b07eded
commit
2ba90581d5
@ -24,6 +24,11 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args: ['-S', '-l', '79']
|
args: ['-S', '-l', '79']
|
||||||
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.6.2
|
||||||
|
hooks:
|
||||||
|
- id: ruff
|
||||||
|
args: ['--fix']
|
||||||
- repo: https://github.com/PyCQA/bandit
|
- repo: https://github.com/PyCQA/bandit
|
||||||
rev: 1.7.9
|
rev: 1.7.9
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -176,7 +176,7 @@ def get_network_quotas(
|
|||||||
default=False,
|
default=False,
|
||||||
):
|
):
|
||||||
def _network_quota_to_dict(network_quota, detail=False):
|
def _network_quota_to_dict(network_quota, detail=False):
|
||||||
if type(network_quota) is not dict:
|
if not isinstance(network_quota, dict):
|
||||||
dict_quota = network_quota.to_dict()
|
dict_quota = network_quota.to_dict()
|
||||||
else:
|
else:
|
||||||
dict_quota = network_quota
|
dict_quota = network_quota
|
||||||
|
@ -577,7 +577,7 @@ class UnsetFlavor(command.Command):
|
|||||||
parsed_args.flavor, get_extra_specs=True, ignore_missing=False
|
parsed_args.flavor, get_extra_specs=True, ignore_missing=False
|
||||||
)
|
)
|
||||||
except sdk_exceptions.ResourceNotFound as e:
|
except sdk_exceptions.ResourceNotFound as e:
|
||||||
raise exceptions.CommandError(_(e.message))
|
raise exceptions.CommandError(e.message)
|
||||||
|
|
||||||
result = 0
|
result = 0
|
||||||
if parsed_args.properties:
|
if parsed_args.properties:
|
||||||
|
@ -253,8 +253,17 @@ def _get_migration_by_uuid(compute_client, server_id, migration_uuid):
|
|||||||
if migration.uuid == migration_uuid:
|
if migration.uuid == migration_uuid:
|
||||||
return migration
|
return migration
|
||||||
else:
|
else:
|
||||||
msg = _('In-progress live migration %s is not found for server %s.')
|
msg = _(
|
||||||
raise exceptions.CommandError(msg % (migration_uuid, server_id))
|
'In-progress live migration %(migration)s is not found for '
|
||||||
|
'server %(server)s'
|
||||||
|
)
|
||||||
|
raise exceptions.CommandError(
|
||||||
|
msg
|
||||||
|
% {
|
||||||
|
'migration': migration_uuid,
|
||||||
|
'server': server_id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ShowMigration(command.ShowOne):
|
class ShowMigration(command.ShowOne):
|
||||||
|
@ -1614,8 +1614,6 @@ class ImportImage(command.ShowOne):
|
|||||||
metavar='<image>',
|
metavar='<image>',
|
||||||
help=_('Image to initiate import process for (name or ID)'),
|
help=_('Image to initiate import process for (name or ID)'),
|
||||||
)
|
)
|
||||||
# TODO(stephenfin): Uncomment help text when we have this command
|
|
||||||
# implemented
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--method',
|
'--method',
|
||||||
metavar='<method>',
|
metavar='<method>',
|
||||||
@ -1630,8 +1628,6 @@ class ImportImage(command.ShowOne):
|
|||||||
help=_(
|
help=_(
|
||||||
"Import method used for image import process. "
|
"Import method used for image import process. "
|
||||||
"Not all deployments will support all methods. "
|
"Not all deployments will support all methods. "
|
||||||
# "Valid values can be retrieved with the 'image import "
|
|
||||||
# "methods' command. "
|
|
||||||
"The 'glance-direct' method (default) requires images be "
|
"The 'glance-direct' method (default) requires images be "
|
||||||
"first staged using the 'image-stage' command."
|
"first staged using the 'image-stage' command."
|
||||||
),
|
),
|
||||||
@ -1734,11 +1730,15 @@ class ImportImage(command.ShowOne):
|
|||||||
|
|
||||||
if parsed_args.import_method not in import_methods:
|
if parsed_args.import_method not in import_methods:
|
||||||
msg = _(
|
msg = _(
|
||||||
"The '%s' import method is not supported by this deployment. "
|
"The '%(method)s' import method is not supported by this "
|
||||||
"Supported: %s"
|
"deployment. Supported: %(supported)s"
|
||||||
)
|
)
|
||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
msg % (parsed_args.import_method, ', '.join(import_methods)),
|
msg
|
||||||
|
% {
|
||||||
|
'method': parsed_args.import_method,
|
||||||
|
'supported': ', '.join(import_methods),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if parsed_args.import_method == 'web-download':
|
if parsed_args.import_method == 'web-download':
|
||||||
|
@ -260,10 +260,12 @@ class ShowMetadefObjectProperty(command.ShowOne):
|
|||||||
prop['name'] = parsed_args.property
|
prop['name'] = parsed_args.property
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
msg = _('Property %s not found in object %s.') % (
|
msg = _(
|
||||||
parsed_args.property,
|
'Property %(property)s not found in object %(object)s.'
|
||||||
parsed_args.object,
|
) % {
|
||||||
)
|
'property': parsed_args.property,
|
||||||
|
'object': parsed_args.object,
|
||||||
|
}
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
return zip(*sorted(prop.items()))
|
return zip(*sorted(prop.items()))
|
||||||
|
@ -171,7 +171,7 @@ class CreateVolumeType(command.ShowOne):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_(
|
help=_(
|
||||||
"Enabled replication for this volume type "
|
"Enabled replication for this volume type "
|
||||||
"(this is an alias for '--property replication_enabled=<is> True') " # noqa: E501
|
"(this is an alias for '--property replication_enabled=<is> True') "
|
||||||
"(requires driver support)"
|
"(requires driver support)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -181,7 +181,7 @@ class CreateVolumeType(command.ShowOne):
|
|||||||
dest='availability_zones',
|
dest='availability_zones',
|
||||||
help=_(
|
help=_(
|
||||||
"Set an availability zone for this volume type "
|
"Set an availability zone for this volume type "
|
||||||
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
|
"(this is an alias for '--property RESKEY:availability_zones:<az>') "
|
||||||
"(repeat option to set multiple availability zones)"
|
"(repeat option to set multiple availability zones)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -535,7 +535,7 @@ class SetVolumeType(command.Command):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_(
|
help=_(
|
||||||
"Enabled replication for this volume type "
|
"Enabled replication for this volume type "
|
||||||
"(this is an alias for '--property replication_enabled=<is> True') " # noqa: E501
|
"(this is an alias for '--property replication_enabled=<is> True') "
|
||||||
"(requires driver support)"
|
"(requires driver support)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -545,7 +545,7 @@ class SetVolumeType(command.Command):
|
|||||||
dest='availability_zones',
|
dest='availability_zones',
|
||||||
help=_(
|
help=_(
|
||||||
"Set an availability zone for this volume type "
|
"Set an availability zone for this volume type "
|
||||||
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
|
"(this is an alias for '--property RESKEY:availability_zones:<az>') "
|
||||||
"(repeat option to set multiple availability zones)"
|
"(repeat option to set multiple availability zones)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -154,7 +154,7 @@ class CreateVolume(volume_v2.CreateVolume):
|
|||||||
"Cinder cluster on which the existing volume resides; "
|
"Cinder cluster on which the existing volume resides; "
|
||||||
"takes the form: cluster@backend-name#pool. This is only "
|
"takes the form: cluster@backend-name#pool. This is only "
|
||||||
"used along with the --remote-source option. "
|
"used along with the --remote-source option. "
|
||||||
"(supported by --os-volume-api-version 3.16 or above)",
|
"(supported by --os-volume-api-version 3.16 or above)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
@ -288,7 +288,7 @@ class DeleteVolumeGroup(command.Command):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_(
|
help=_(
|
||||||
'Delete the volume group even if it contains volumes. '
|
'Delete the volume group even if it contains volumes. '
|
||||||
'This will delete any remaining volumes in the group.',
|
'This will delete any remaining volumes in the group.'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
@ -582,18 +582,14 @@ class FailoverVolumeGroup(command.Command):
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
dest='allow_attached_volume',
|
dest='allow_attached_volume',
|
||||||
default=False,
|
default=False,
|
||||||
help=_(
|
help=_('Allow group with attached volumes to be failed over.'),
|
||||||
'Allow group with attached volumes to be failed over.',
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--disallow-attached-volume',
|
'--disallow-attached-volume',
|
||||||
action='store_false',
|
action='store_false',
|
||||||
dest='allow_attached_volume',
|
dest='allow_attached_volume',
|
||||||
default=False,
|
default=False,
|
||||||
help=_(
|
help=_('Disallow group with attached volumes to be failed over.'),
|
||||||
'Disallow group with attached volumes to be failed over.',
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--secondary-backend-id',
|
'--secondary-backend-id',
|
||||||
|
@ -172,7 +172,7 @@ class CreateVolumeType(command.ShowOne):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_(
|
help=_(
|
||||||
"Enabled replication for this volume type "
|
"Enabled replication for this volume type "
|
||||||
"(this is an alias for '--property replication_enabled=<is> True') " # noqa: E501
|
"(this is an alias for '--property replication_enabled=<is> True') "
|
||||||
"(requires driver support)"
|
"(requires driver support)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -182,7 +182,7 @@ class CreateVolumeType(command.ShowOne):
|
|||||||
dest='availability_zones',
|
dest='availability_zones',
|
||||||
help=_(
|
help=_(
|
||||||
"Set an availability zone for this volume type "
|
"Set an availability zone for this volume type "
|
||||||
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
|
"(this is an alias for '--property RESKEY:availability_zones:<az>') "
|
||||||
"(repeat option to set multiple availability zones)"
|
"(repeat option to set multiple availability zones)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -448,7 +448,7 @@ class ListVolumeType(command.Lister):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_(
|
help=_(
|
||||||
"List only volume types with replication enabled "
|
"List only volume types with replication enabled "
|
||||||
"(this is an alias for '--property replication_enabled=<is> True') " # noqa: E501
|
"(this is an alias for '--property replication_enabled=<is> True') "
|
||||||
"(supported by --os-volume-api-version 3.52 or above)"
|
"(supported by --os-volume-api-version 3.52 or above)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -458,7 +458,7 @@ class ListVolumeType(command.Lister):
|
|||||||
dest='availability_zones',
|
dest='availability_zones',
|
||||||
help=_(
|
help=_(
|
||||||
"List only volume types with this availability configured "
|
"List only volume types with this availability configured "
|
||||||
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
|
"(this is an alias for '--property RESKEY:availability_zones:<az>') "
|
||||||
"(repeat option to filter on multiple availability zones)"
|
"(repeat option to filter on multiple availability zones)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -617,7 +617,7 @@ class SetVolumeType(command.Command):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_(
|
help=_(
|
||||||
"Enabled replication for this volume type "
|
"Enabled replication for this volume type "
|
||||||
"(this is an alias for '--property replication_enabled=<is> True') " # noqa: E501
|
"(this is an alias for '--property replication_enabled=<is> True') "
|
||||||
"(requires driver support)"
|
"(requires driver support)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -627,7 +627,7 @@ class SetVolumeType(command.Command):
|
|||||||
dest='availability_zones',
|
dest='availability_zones',
|
||||||
help=_(
|
help=_(
|
||||||
"Set an availability zone for this volume type "
|
"Set an availability zone for this volume type "
|
||||||
"(this is an alias for '--property RESKEY:availability_zones:<az>') " # noqa: E501
|
"(this is an alias for '--property RESKEY:availability_zones:<az>') "
|
||||||
"(repeat option to set multiple availability zones)"
|
"(repeat option to set multiple availability zones)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
8
tox.ini
8
tox.ini
@ -113,11 +113,9 @@ commands =
|
|||||||
[flake8]
|
[flake8]
|
||||||
show-source = true
|
show-source = true
|
||||||
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,releasenotes
|
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,releasenotes
|
||||||
# E203 Black will put spaces after colons in list comprehensions
|
# We only enable the hacking (H) checks
|
||||||
# E501 Black takes care of line length for us
|
select = H
|
||||||
# E704 Black will occasionally put multiple statements on one line
|
|
||||||
# H301 Black will put commas after imports that can't fit on one line
|
# H301 Black will put commas after imports that can't fit on one line
|
||||||
# W503 and W504 are disabled since they're not very useful
|
ignore = H301
|
||||||
ignore = E203, E501, E701, H301, W503, W504
|
|
||||||
import-order-style = pep8
|
import-order-style = pep8
|
||||||
application_import_names = openstackclient
|
application_import_names = openstackclient
|
||||||
|
Loading…
x
Reference in New Issue
Block a user