pre-commit: Migrate from black to ruff format
Change-Id: I28ca7d31d30272002799f3e2832105dc67c60538 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
17e6545fd4
commit
519fa7aabc
@ -19,16 +19,12 @@ repos:
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ['--py38-plus']
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 24.8.0
|
||||
hooks:
|
||||
- id: black
|
||||
args: ['-S', '-l', '79']
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.6.2
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: ['--fix']
|
||||
- id: ruff-format
|
||||
- repo: https://github.com/PyCQA/bandit
|
||||
rev: 1.7.9
|
||||
hooks:
|
||||
|
@ -12,6 +12,7 @@
|
||||
#
|
||||
|
||||
"""Base API Library"""
|
||||
|
||||
from keystoneauth1 import exceptions as ks_exceptions
|
||||
from keystoneauth1 import session as ks_session
|
||||
from osc_lib import exceptions
|
||||
|
@ -33,7 +33,7 @@ class APIv2(image_v1.APIv1):
|
||||
private=False,
|
||||
community=False,
|
||||
shared=False,
|
||||
**filter
|
||||
**filter,
|
||||
):
|
||||
"""Get available images
|
||||
|
||||
|
@ -89,7 +89,7 @@ class APIv1(api.BaseAPI):
|
||||
marker=None,
|
||||
end_marker=None,
|
||||
prefix=None,
|
||||
**params
|
||||
**params,
|
||||
):
|
||||
"""Get containers in an account
|
||||
|
||||
@ -116,7 +116,7 @@ class APIv1(api.BaseAPI):
|
||||
marker=marker,
|
||||
end_marker=end_marker,
|
||||
prefix=prefix,
|
||||
**params
|
||||
**params,
|
||||
)
|
||||
while listing:
|
||||
marker = listing[-1]['name']
|
||||
@ -125,7 +125,7 @@ class APIv1(api.BaseAPI):
|
||||
marker=marker,
|
||||
end_marker=end_marker,
|
||||
prefix=prefix,
|
||||
**params
|
||||
**params,
|
||||
)
|
||||
if listing:
|
||||
data.extend(listing)
|
||||
@ -306,7 +306,7 @@ class APIv1(api.BaseAPI):
|
||||
end_marker=None,
|
||||
delimiter=None,
|
||||
prefix=None,
|
||||
**params
|
||||
**params,
|
||||
):
|
||||
"""List objects in a container
|
||||
|
||||
@ -341,7 +341,7 @@ class APIv1(api.BaseAPI):
|
||||
end_marker=end_marker,
|
||||
prefix=prefix,
|
||||
delimiter=delimiter,
|
||||
**params
|
||||
**params,
|
||||
)
|
||||
while listing:
|
||||
if delimiter:
|
||||
@ -355,7 +355,7 @@ class APIv1(api.BaseAPI):
|
||||
end_marker=end_marker,
|
||||
prefix=prefix,
|
||||
delimiter=delimiter,
|
||||
**params
|
||||
**params,
|
||||
)
|
||||
if listing:
|
||||
data.extend(listing)
|
||||
|
@ -87,7 +87,7 @@ class CreateProject(command.ShowOne):
|
||||
parsed_args.name,
|
||||
description=parsed_args.description,
|
||||
enabled=enabled,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
except ks_exc.Conflict:
|
||||
if parsed_args.or_show:
|
||||
|
@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
"""Identity v2 Assignment action implementations """
|
||||
"""Identity v2 Assignment action implementations"""
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
|
@ -133,7 +133,7 @@ class CreateIdentityProvider(command.ShowOne):
|
||||
description=parsed_args.description,
|
||||
domain_id=domain_id,
|
||||
enabled=parsed_args.enabled,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
idp._info.pop('links', None)
|
||||
|
@ -125,7 +125,7 @@ class CreateProject(command.ShowOne):
|
||||
description=parsed_args.description,
|
||||
enabled=enabled,
|
||||
options=options,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
except ks_exc.Conflict:
|
||||
if parsed_args.or_show:
|
||||
|
@ -245,7 +245,7 @@ class SetConntrackHelper(command.Command):
|
||||
client.update_conntrack_helper(
|
||||
parsed_args.conntrack_helper_id,
|
||||
attrs.pop('router_id'),
|
||||
**attrs
|
||||
**attrs,
|
||||
)
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
"""Router NDP proxy action implementations"""
|
||||
|
||||
import logging
|
||||
|
||||
from osc_lib.command import command
|
||||
|
@ -15,6 +15,7 @@
|
||||
#
|
||||
|
||||
"""Network trunk and subports action implementations"""
|
||||
|
||||
import logging
|
||||
|
||||
from cliff import columns as cliff_columns
|
||||
@ -67,8 +68,8 @@ class CreateNetworkTrunk(command.ShowOne):
|
||||
required_keys=['port'],
|
||||
help=_(
|
||||
"Subport to add. Subport is of form "
|
||||
"\'port=<name or ID>,segmentation-type=<segmentation-type>,"
|
||||
"segmentation-id=<segmentation-ID>\' (--subport) option "
|
||||
"'port=<name or ID>,segmentation-type=<segmentation-type>,"
|
||||
"segmentation-id=<segmentation-ID>' (--subport) option "
|
||||
"can be repeated"
|
||||
),
|
||||
)
|
||||
@ -198,8 +199,8 @@ class SetNetworkTrunk(command.Command):
|
||||
required_keys=['port'],
|
||||
help=_(
|
||||
"Subport to add. Subport is of form "
|
||||
"\'port=<name or ID>,segmentation-type=<segmentation-type>"
|
||||
",segmentation-id=<segmentation-ID>\' (--subport) option "
|
||||
"'port=<name or ID>,segmentation-type=<segmentation-type>"
|
||||
",segmentation-id=<segmentation-ID>' (--subport) option "
|
||||
"can be repeated"
|
||||
),
|
||||
)
|
||||
|
@ -164,10 +164,13 @@ def _get_external_gateway_attrs(client_manager, parsed_args):
|
||||
'subnet_id' in ip_spec
|
||||
and ip_net_id not in external_gateways
|
||||
):
|
||||
msg = _(
|
||||
'Subnet %s does not belong to any of the networks '
|
||||
'provided for --external-gateway.'
|
||||
) % (ip_spec['subnet_id'])
|
||||
msg = (
|
||||
_(
|
||||
'Subnet %s does not belong to any of the networks '
|
||||
'provided for --external-gateway.'
|
||||
)
|
||||
% (ip_spec['subnet_id'])
|
||||
)
|
||||
raise exceptions.CommandError(msg)
|
||||
for gw_info in external_gateways[ip_net_id]:
|
||||
if 'external_fixed_ips' not in gw_info:
|
||||
|
@ -26,7 +26,6 @@ from openstackclient.tests.unit import utils
|
||||
|
||||
|
||||
class TestSecurityGroup(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -227,7 +226,6 @@ class TestSecurityGroup(utils.TestCase):
|
||||
|
||||
|
||||
class TestSecurityGroupRule(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -290,7 +288,6 @@ class TestSecurityGroupRule(utils.TestCase):
|
||||
|
||||
|
||||
class TestNetwork(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -457,7 +454,6 @@ class TestNetwork(utils.TestCase):
|
||||
|
||||
|
||||
class TestFloatingIP(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -547,7 +543,6 @@ class TestFloatingIP(utils.TestCase):
|
||||
|
||||
|
||||
class TestFloatingIPPool(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
|
@ -59,7 +59,6 @@ def _generate_fake_host():
|
||||
|
||||
|
||||
class TestHostList(compute_fakes.TestComputev2):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
|
@ -7363,9 +7363,7 @@ class TestServerRemoveSecurityGroup(TestServer):
|
||||
|
||||
self.server = compute_fakes.create_one_sdk_server()
|
||||
self.compute_sdk_client.find_server.return_value = self.server
|
||||
self.compute_sdk_client.remove_security_group_from_server.return_value = (
|
||||
None
|
||||
)
|
||||
self.compute_sdk_client.remove_security_group_from_server.return_value = None
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = server.RemoveServerSecurityGroup(self.app, None)
|
||||
|
@ -90,7 +90,7 @@ class TestLimitCreate(TestLimit):
|
||||
self.service,
|
||||
identity_fakes.limit_resource_name,
|
||||
resource_limit,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
collist = (
|
||||
@ -154,7 +154,7 @@ class TestLimitCreate(TestLimit):
|
||||
self.service,
|
||||
identity_fakes.limit_resource_name,
|
||||
resource_limit,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
collist = (
|
||||
|
@ -42,9 +42,7 @@ class TestMetadefResourceTypeAssociationCreate(
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.image_client.create_metadef_resource_type_association.return_value = (
|
||||
self.resource_type_association
|
||||
)
|
||||
self.image_client.create_metadef_resource_type_association.return_value = self.resource_type_association
|
||||
self.cmd = metadef_resource_type_association.CreateMetadefResourceTypeAssociation(
|
||||
self.app, None
|
||||
)
|
||||
@ -74,9 +72,7 @@ class TestMetadefResourceTypeAssociationDelete(
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.image_client.delete_metadef_resource_type_association.return_value = (
|
||||
self.resource_type_association
|
||||
)
|
||||
self.image_client.delete_metadef_resource_type_association.return_value = self.resource_type_association
|
||||
self.cmd = metadef_resource_type_association.DeleteMetadefResourceTypeAssociation(
|
||||
self.app, None
|
||||
)
|
||||
|
@ -79,7 +79,7 @@ class TestCreateDefaultSecurityGroupRule(TestDefaultSecurityGroupRule):
|
||||
default_security_group_rule_attrs.update(attrs)
|
||||
self._default_sg_rule = sdk_fakes.generate_fake_resource(
|
||||
_default_security_group_rule.DefaultSecurityGroupRule,
|
||||
**default_security_group_rule_attrs
|
||||
**default_security_group_rule_attrs,
|
||||
)
|
||||
|
||||
self.sdk_client.create_default_security_group_rule.return_value = (
|
||||
@ -956,11 +956,11 @@ class TestListDefaultSecurityGroupRule(TestDefaultSecurityGroupRule):
|
||||
# The security group rule to be listed.
|
||||
_default_sg_rule_tcp = sdk_fakes.generate_fake_resource(
|
||||
_default_security_group_rule.DefaultSecurityGroupRule,
|
||||
**{'protocol': 'tcp', 'port_range_max': 80, 'port_range_min': 80}
|
||||
**{'protocol': 'tcp', 'port_range_max': 80, 'port_range_min': 80},
|
||||
)
|
||||
_default_sg_rule_icmp = sdk_fakes.generate_fake_resource(
|
||||
_default_security_group_rule.DefaultSecurityGroupRule,
|
||||
**{'protocol': 'icmp', 'remote_ip_prefix': '10.0.2.0/24'}
|
||||
**{'protocol': 'icmp', 'remote_ip_prefix': '10.0.2.0/24'},
|
||||
)
|
||||
_default_sg_rules = [
|
||||
_default_sg_rule_tcp,
|
||||
|
@ -153,7 +153,7 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
'internal_port_id': self.new_port_forwarding_with_ranges.internal_port_id, # noqa: E501
|
||||
'protocol': self.new_port_forwarding_with_ranges.protocol,
|
||||
'description': self.new_port_forwarding_with_ranges.description, # noqa: E501
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, data)
|
||||
@ -334,7 +334,7 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
'internal_port_id': self.new_port_forwarding.internal_port_id,
|
||||
'protocol': self.new_port_forwarding.protocol,
|
||||
'description': self.new_port_forwarding.description,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, data)
|
||||
@ -587,7 +587,7 @@ class TestSetFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
self.network_client.update_floating_ip_port_forwarding.assert_called_with(
|
||||
self._port_forwarding.floatingip_id,
|
||||
self._port_forwarding.id,
|
||||
**attrs
|
||||
**attrs,
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
@ -648,7 +648,7 @@ class TestSetFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
self.network_client.update_floating_ip_port_forwarding.assert_called_with(
|
||||
self._port_forwarding.floatingip_id,
|
||||
self._port_forwarding.id,
|
||||
**attrs
|
||||
**attrs,
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
@ -86,7 +86,7 @@ class TestCreateLocalIPAssociation(TestLocalIPAssociation):
|
||||
self.new_local_ip_association.local_ip_id,
|
||||
**{
|
||||
'fixed_port_id': self.new_local_ip_association.fixed_port_id,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(set(self.columns), set(columns))
|
||||
self.assertEqual(set(self.data), set(data))
|
||||
@ -111,7 +111,7 @@ class TestCreateLocalIPAssociation(TestLocalIPAssociation):
|
||||
**{
|
||||
'fixed_port_id': self.new_local_ip_association.fixed_port_id,
|
||||
'fixed_ip': self.new_local_ip_association.fixed_ip,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(set(self.columns), set(columns))
|
||||
self.assertEqual(set(self.data), set(data))
|
||||
|
@ -137,7 +137,7 @@ class TestCreateNetworkQosRuleMinimumBandwidth(TestNetworkQosRule):
|
||||
**{
|
||||
'min_kbps': self.new_rule.min_kbps,
|
||||
'direction': self.new_rule.direction,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, data)
|
||||
@ -244,7 +244,7 @@ class TestCreateNetworkQosRuleMinimumPacketRate(TestNetworkQosRule):
|
||||
**{
|
||||
'min_kpps': self.new_rule.min_kpps,
|
||||
'direction': self.new_rule.direction,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, data)
|
||||
@ -473,7 +473,7 @@ class TestCreateNetworkQosRuleBandwidtLimit(TestNetworkQosRule):
|
||||
**{
|
||||
'max_kbps': self.new_rule.max_kbps,
|
||||
'direction': self.new_rule.direction,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(expected_data, data)
|
||||
@ -507,7 +507,7 @@ class TestCreateNetworkQosRuleBandwidtLimit(TestNetworkQosRule):
|
||||
'max_kbps': self.new_rule.max_kbps,
|
||||
'max_burst_kbps': self.new_rule.max_burst_kbits,
|
||||
'direction': self.new_rule.direction,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, data)
|
||||
|
@ -1006,7 +1006,7 @@ class TestSetSubnetPool(TestSubnetPool):
|
||||
self._subnet_pool,
|
||||
**{
|
||||
'default_quota': 20,
|
||||
}
|
||||
},
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
@ -352,7 +352,7 @@ class TestObjectShow(TestObject):
|
||||
c_mock.assert_called_with(
|
||||
container=object_fakes.container_name,
|
||||
object=object_fakes.object_name_1,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
collist = ('bytes', 'content_type', 'hash', 'last_modified', 'name')
|
||||
|
@ -93,7 +93,7 @@ def make_client(instance):
|
||||
region_name=instance.region_name,
|
||||
endpoint_override=endpoint_override,
|
||||
api_version=version,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return client
|
||||
|
@ -21,7 +21,6 @@ from openstackclient.volume.v2 import service as service_v2
|
||||
|
||||
|
||||
class ListService(service_v2.ListService):
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
service_client = self.app.client_manager.volume
|
||||
|
||||
|
6
pyproject.toml
Normal file
6
pyproject.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[tool.ruff]
|
||||
line-length = 79
|
||||
|
||||
[tool.ruff.format]
|
||||
quote-style = "preserve"
|
||||
docstring-code-format = true
|
Loading…
x
Reference in New Issue
Block a user