Merge "trivial: Enable ruff-specific (RUF) rules"
This commit is contained in:
@@ -254,7 +254,7 @@ class BaseAPI(KeystoneSession):
|
||||
items = self.list(path)
|
||||
if isinstance(items, dict):
|
||||
# strip off the enclosing dict
|
||||
key = list(items.keys())[0]
|
||||
key = next(iter(items.keys()))
|
||||
items = items[key]
|
||||
|
||||
ret = []
|
||||
|
||||
@@ -40,7 +40,7 @@ class _ProgressBarBase:
|
||||
# Output something like this: [==========> ] 49%
|
||||
sys.stdout.write(
|
||||
'\r[{:<30}] {:.0%}'.format(
|
||||
'=' * int(round(self._percent * 29)) + '>', self._percent
|
||||
'=' * round(self._percent * 29) + '>', self._percent
|
||||
)
|
||||
)
|
||||
sys.stdout.flush()
|
||||
|
||||
@@ -827,13 +827,11 @@ and ``server-group-members`` output for a given quota class."""
|
||||
_normalize_names(info["usage"])
|
||||
|
||||
# Remove the 'id' field since it's not very useful
|
||||
if 'id' in info:
|
||||
del info['id']
|
||||
info.pop('id', None)
|
||||
|
||||
# Remove the sdk-derived fields
|
||||
for field in ('location', 'name', 'force'):
|
||||
if field in info:
|
||||
del info[field]
|
||||
info.pop(field, None)
|
||||
|
||||
if not parsed_args.usage:
|
||||
result = [{'resource': k, 'limit': v} for k, v in info.items()]
|
||||
|
||||
@@ -940,9 +940,9 @@ class NICAction(argparse.Action):
|
||||
}
|
||||
|
||||
for kv_str in values.split(','):
|
||||
k, sep, v = kv_str.partition('=')
|
||||
k, _sep, v = kv_str.partition('=')
|
||||
|
||||
if k not in list(info) + ['tag'] or not v:
|
||||
if k not in [*list(info), 'tag'] or not v:
|
||||
msg = _(
|
||||
"Invalid argument %s; argument must be of form "
|
||||
"'net-id=net-uuid,port-id=port-uuid,v4-fixed-ip=ip-addr,"
|
||||
@@ -975,7 +975,7 @@ class BDMLegacyAction(argparse.Action):
|
||||
if getattr(namespace, self.dest, None) is None:
|
||||
setattr(namespace, self.dest, [])
|
||||
|
||||
dev_name, sep, dev_map = values.partition('=')
|
||||
dev_name, _sep, dev_map = values.partition('=')
|
||||
dev_map = dev_map.split(':') if dev_map else dev_map
|
||||
if not dev_name or not dev_map or len(dev_map) > 4:
|
||||
msg = _(
|
||||
@@ -5017,7 +5017,7 @@ class SshServer(command.Command):
|
||||
ip_address_family,
|
||||
)
|
||||
|
||||
cmd = ' '.join(['ssh', ip_address] + args)
|
||||
cmd = ' '.join(['ssh', ip_address, *args])
|
||||
LOG.debug('ssh command: %s', cmd)
|
||||
# we intentionally pass through user-provided arguments and run this in
|
||||
# the user's shell
|
||||
|
||||
@@ -180,7 +180,7 @@ def _get_token_resource(client, resource, parsed_name, parsed_domain=None):
|
||||
return parsed_name
|
||||
return obj['id'] if obj['name'] == parsed_name else parsed_name
|
||||
# diaper defense in case parsing the token fails
|
||||
except Exception: # noqa
|
||||
except Exception:
|
||||
return parsed_name
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
|
||||
from openstackclient import command
|
||||
from openstackclient.i18n import _ # noqa
|
||||
from openstackclient.i18n import _
|
||||
|
||||
|
||||
class ListRoleAssignment(command.Lister):
|
||||
|
||||
@@ -188,13 +188,13 @@ class ListIdentityProvider(command.Lister):
|
||||
parser.add_argument(
|
||||
'--id',
|
||||
metavar='<id>',
|
||||
help=_('The Identity Providers’ ID attribute'),
|
||||
help=_('Filter identity providers by ID'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--enabled',
|
||||
dest='enabled',
|
||||
action='store_true',
|
||||
help=_('The Identity Providers that are enabled will be returned'),
|
||||
help=_('List only enabled identity providers'),
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
@@ -416,8 +416,10 @@ class ListRole(command.Lister):
|
||||
return (
|
||||
('ID', 'Name', 'Domain'),
|
||||
(
|
||||
utils.get_item_properties(s, ('id', 'name'))
|
||||
+ (domain.name,)
|
||||
(
|
||||
*utils.get_item_properties(s, ('id', 'name')),
|
||||
domain.name,
|
||||
)
|
||||
for s in data
|
||||
),
|
||||
)
|
||||
|
||||
@@ -299,7 +299,7 @@ class CreateImage(command.ShowOne):
|
||||
volume_client.volumes,
|
||||
parsed_args.volume,
|
||||
)
|
||||
response, body = volume_client.volumes.upload_to_image(
|
||||
_response, body = volume_client.volumes.upload_to_image(
|
||||
source_volume.id,
|
||||
parsed_args.force,
|
||||
parsed_args.name,
|
||||
@@ -498,7 +498,7 @@ class ListImage(command.Lister):
|
||||
|
||||
if parsed_args.property:
|
||||
# NOTE(dtroyer): coerce to a list to subscript it in py3
|
||||
attr, value = list(parsed_args.property.items())[0]
|
||||
attr, value = next(iter(parsed_args.property.items()))
|
||||
api_utils.simple_filter(
|
||||
images,
|
||||
attr=attr,
|
||||
|
||||
@@ -78,7 +78,7 @@ def str2dict(strdict: str) -> dict[str, str]:
|
||||
else:
|
||||
kvlist[i - 1] = f"{kvlist[i - 1]};{kv}"
|
||||
for kv in kvlist:
|
||||
key, sep, value = kv.partition(':')
|
||||
key, value = kv.split(':', 1)
|
||||
result[key] = value
|
||||
return result
|
||||
|
||||
@@ -173,11 +173,15 @@ def is_ipv6_protocol(protocol):
|
||||
# However, while the OSC CLI doesn't document the protocol,
|
||||
# the code must still handle it. In addition, handle both
|
||||
# protocol names and numbers.
|
||||
if (
|
||||
protocol is not None
|
||||
and protocol.startswith('ipv6-')
|
||||
or protocol in ['icmpv6', '41', '43', '44', '58', '59', '60']
|
||||
):
|
||||
if (protocol is not None and protocol.startswith('ipv6-')) or protocol in [
|
||||
'icmpv6',
|
||||
'41',
|
||||
'43',
|
||||
'44',
|
||||
'58',
|
||||
'59',
|
||||
'60',
|
||||
]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -406,14 +406,21 @@ class ListNetworkSegmentRange(command.Lister):
|
||||
for s in data:
|
||||
props = utils.get_item_properties(s, columns)
|
||||
if (
|
||||
parsed_args.available
|
||||
and _is_prop_empty(columns, props, 'available')
|
||||
or parsed_args.unavailable
|
||||
and not _is_prop_empty(columns, props, 'available')
|
||||
or parsed_args.used
|
||||
and _is_prop_empty(columns, props, 'used')
|
||||
or parsed_args.unused
|
||||
and not _is_prop_empty(columns, props, 'used')
|
||||
(
|
||||
parsed_args.available
|
||||
and _is_prop_empty(columns, props, 'available')
|
||||
)
|
||||
or (
|
||||
parsed_args.unavailable
|
||||
and not _is_prop_empty(columns, props, 'available')
|
||||
)
|
||||
or (
|
||||
parsed_args.used and _is_prop_empty(columns, props, 'used')
|
||||
)
|
||||
or (
|
||||
parsed_args.unused
|
||||
and not _is_prop_empty(columns, props, 'used')
|
||||
)
|
||||
):
|
||||
continue
|
||||
if parsed_args.long:
|
||||
|
||||
@@ -92,7 +92,7 @@ class TestCase(testtools.TestCase):
|
||||
format_args.append('-f json')
|
||||
|
||||
output = execute(
|
||||
' '.join(['openstack'] + auth_args + [cmd] + format_args),
|
||||
' '.join(['openstack', *auth_args, cmd, *format_args]),
|
||||
fail_ok=fail_ok,
|
||||
)
|
||||
|
||||
|
||||
@@ -105,6 +105,6 @@ class ProjectTests(common.IdentityTests):
|
||||
f'{self.project_name}',
|
||||
parse_output=True,
|
||||
)
|
||||
for attr_name in self.PROJECT_FIELDS + ['parents', 'subtree']:
|
||||
for attr_name in [*self.PROJECT_FIELDS, 'parents', 'subtree']:
|
||||
self.assertIn(attr_name, output)
|
||||
self.assertEqual(self.project_name, output.get('name'))
|
||||
|
||||
@@ -84,7 +84,7 @@ class NetworkTagTests(NetworkTests):
|
||||
parse_output=True,
|
||||
)
|
||||
for name, tags in expected:
|
||||
net = [n for n in cmd_output if n['Name'] == name][0]
|
||||
net = next(n for n in cmd_output if n['Name'] == name)
|
||||
self.assertEqual(set(tags), set(net['Tags']))
|
||||
|
||||
def _create_resource_for_tag_test(self, name, args):
|
||||
|
||||
@@ -173,9 +173,9 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type list --encryption-type',
|
||||
parse_output=True,
|
||||
)
|
||||
encryption_output = [
|
||||
encryption_output = next(
|
||||
t['Encryption'] for t in cmd_output if t['Name'] == encryption_type
|
||||
][0]
|
||||
)
|
||||
expected = {
|
||||
'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
|
||||
@@ -173,9 +173,9 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
'volume type list --encryption-type',
|
||||
parse_output=True,
|
||||
)
|
||||
encryption_output = [
|
||||
encryption_output = next(
|
||||
t['Encryption'] for t in cmd_output if t['Name'] == encryption_type
|
||||
][0]
|
||||
)
|
||||
expected = {
|
||||
'provider': 'LuksEncryptor',
|
||||
'cipher': 'aes-xts-plain64',
|
||||
|
||||
@@ -458,7 +458,7 @@ class TestQuotaSet(TestQuota):
|
||||
'floating_ips': floating_ip_num,
|
||||
'fixed_ips': fix_ip_num,
|
||||
'injected_files': injected_file_num,
|
||||
'injected_file_content_bytes': injected_file_size_num, # noqa: E501
|
||||
'injected_file_content_bytes': injected_file_size_num,
|
||||
'injected_file_path_bytes': injected_path_size_num,
|
||||
'key_pairs': key_pair_num,
|
||||
'cores': core_num,
|
||||
@@ -729,7 +729,7 @@ class TestQuotaSet(TestQuota):
|
||||
|
||||
kwargs_compute = {
|
||||
'injected_files': injected_file_num,
|
||||
'injected_file_content_bytes': injected_file_size_num, # noqa: E501
|
||||
'injected_file_content_bytes': injected_file_size_num,
|
||||
'injected_file_path_bytes': injected_path_size_num,
|
||||
'key_pairs': key_pair_num,
|
||||
'cores': core_num,
|
||||
@@ -827,7 +827,7 @@ class TestQuotaSet(TestQuota):
|
||||
|
||||
kwargs_compute = {
|
||||
'injected_files': injected_file_num,
|
||||
'injected_file_content_bytes': injected_file_size_num, # noqa: E501
|
||||
'injected_file_content_bytes': injected_file_size_num,
|
||||
'injected_file_path_bytes': injected_path_size_num,
|
||||
'key_pairs': key_pair_num,
|
||||
'cores': core_num,
|
||||
|
||||
@@ -494,7 +494,8 @@ class TestFlavorList(TestFlavor):
|
||||
'VCPUs',
|
||||
'Is Public',
|
||||
)
|
||||
self.columns_long = self.columns + (
|
||||
self.columns_long = (
|
||||
*self.columns,
|
||||
'Swap',
|
||||
'RXTX Factor',
|
||||
'Properties',
|
||||
|
||||
@@ -4865,7 +4865,7 @@ class TestServerList(_TestServerList):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.compute_client.servers.assert_called_with(**self.kwargs)
|
||||
self.assertIn('Project ID', columns)
|
||||
@@ -5329,7 +5329,7 @@ class TestServerList(_TestServerList):
|
||||
]
|
||||
|
||||
# Add the expected host_status column and data.
|
||||
columns_long = self.columns_long + ('Host Status',)
|
||||
columns_long = (*self.columns_long, 'Host Status')
|
||||
self.data2 = tuple(
|
||||
(
|
||||
s.id,
|
||||
@@ -5560,7 +5560,7 @@ class TestServerListV273(_TestServerList):
|
||||
}
|
||||
fake_server = _server.Server(**server_dict)
|
||||
self.servers.append(fake_server)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
_columns, data = self.cmd.take_action(parsed_args)
|
||||
# get the first three servers out since our interest is in the partial
|
||||
# server.
|
||||
next(data)
|
||||
@@ -5708,7 +5708,7 @@ class TestServerListV296(_TestServerList):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.compute_client.servers.assert_called_with(**self.kwargs)
|
||||
self.assertIn('Project ID', columns)
|
||||
@@ -5860,7 +5860,7 @@ class TestServerListV2100(_TestServerList):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.compute_client.servers.assert_called_with(**self.kwargs)
|
||||
self.assertIn('Project ID', columns)
|
||||
@@ -8896,7 +8896,7 @@ class TestServerShow(TestServer):
|
||||
None, # OS-EXT-SRV-ATTR:user_data
|
||||
server.PowerStateColumn(
|
||||
self.server.power_state
|
||||
), # OS-EXT-STS:power_state # noqa: E501
|
||||
), # OS-EXT-STS:power_state
|
||||
None, # OS-EXT-STS:task_state
|
||||
None, # OS-EXT-STS:vm_state
|
||||
None, # OS-SRV-USG:launched_at
|
||||
|
||||
@@ -103,7 +103,7 @@ class TestGroupAddUser(identity_fakes.TestIdentityv3):
|
||||
except exceptions.CommandError as e:
|
||||
msg = f"1 of 2 users not added to group {self._group.name}."
|
||||
self.assertEqual(msg, str(e))
|
||||
msg = f"{self.users[0].name} not added to group {self._group.name}: {str(sdk_exc.ResourceNotFound())}"
|
||||
msg = f"{self.users[0].name} not added to group {self._group.name}: {sdk_exc.ResourceNotFound()!s}"
|
||||
mock_error.assert_called_once_with(msg)
|
||||
|
||||
|
||||
@@ -587,10 +587,7 @@ class TestGroupList(identity_fakes.TestIdentityv3):
|
||||
|
||||
self.identity_sdk_client.groups.assert_called_with()
|
||||
|
||||
long_columns = self.columns + (
|
||||
'Domain ID',
|
||||
'Description',
|
||||
)
|
||||
long_columns = (*self.columns, 'Domain ID', 'Description')
|
||||
datalist = (
|
||||
(
|
||||
self.group.id,
|
||||
@@ -687,7 +684,7 @@ class TestGroupRemoveUser(identity_fakes.TestIdentityv3):
|
||||
except exceptions.CommandError as e:
|
||||
msg = f"1 of 2 users not removed from group {self._group.id}."
|
||||
self.assertEqual(msg, str(e))
|
||||
msg = f"{self.users[0].id} not removed from group {self._group.id}: {str(sdk_exc.ResourceNotFound())}"
|
||||
msg = f"{self.users[0].id} not removed from group {self._group.id}: {sdk_exc.ResourceNotFound()!s}"
|
||||
mock_error.assert_called_once_with(msg)
|
||||
|
||||
|
||||
|
||||
@@ -1773,7 +1773,7 @@ class TestUserShow(identity_fakes.TestIdentityv3):
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = user.ShowUser(self.app, None)
|
||||
self.identity_client.auth.client.get_user_id.return_value = ( # noqa: E501
|
||||
self.identity_client.auth.client.get_user_id.return_value = (
|
||||
self.user.id
|
||||
)
|
||||
self.identity_client.tokens.get_token_data.return_value = {
|
||||
|
||||
@@ -305,7 +305,7 @@ class TestImageCreate(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.image_client.create_image.assert_called_with(
|
||||
name=self.new_image.name,
|
||||
@@ -336,7 +336,7 @@ class TestImageCreate(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.volume_sdk_client.upload_volume_to_image.assert_called_once_with(
|
||||
volume.id,
|
||||
@@ -397,7 +397,7 @@ class TestImageCreate(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.volume_sdk_client.upload_volume_to_image.assert_called_once_with(
|
||||
volume.id,
|
||||
@@ -946,7 +946,7 @@ class TestImageList(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.image_client.images.assert_called_with(
|
||||
marker=self._image.id,
|
||||
)
|
||||
@@ -966,7 +966,7 @@ class TestImageList(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.image_client.images.assert_called_with(
|
||||
name='abc',
|
||||
# marker=self._image.id
|
||||
@@ -982,7 +982,7 @@ class TestImageList(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.image_client.images.assert_called_with(status='active')
|
||||
|
||||
def test_image_list_hidden_option(self):
|
||||
@@ -994,7 +994,7 @@ class TestImageList(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.image_client.images.assert_called_with(is_hidden=True)
|
||||
|
||||
def test_image_list_tag_option(self):
|
||||
@@ -1004,7 +1004,7 @@ class TestImageList(TestImage):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.image_client.images.assert_called_with(tag=['abc', 'cba'])
|
||||
|
||||
|
||||
@@ -1329,7 +1329,7 @@ class TestImageSet(TestImage):
|
||||
self.image_client.update_image.assert_called()
|
||||
call_args = self.image_client.update_image.call_args
|
||||
if call_args:
|
||||
args, kwargs = call_args
|
||||
_args, kwargs = call_args
|
||||
self.assertNotIn('owner_id', kwargs)
|
||||
|
||||
def test_image_set_membership_reject_with_project_no_owner_change(self):
|
||||
@@ -1366,7 +1366,7 @@ class TestImageSet(TestImage):
|
||||
self.image_client.update_image.assert_called()
|
||||
call_args = self.image_client.update_image.call_args
|
||||
if call_args:
|
||||
args, kwargs = call_args
|
||||
_args, kwargs = call_args
|
||||
self.assertNotIn('owner_id', kwargs)
|
||||
|
||||
def test_image_set_membership_pending_with_project_no_owner_change(self):
|
||||
@@ -1403,7 +1403,7 @@ class TestImageSet(TestImage):
|
||||
self.image_client.update_image.assert_called()
|
||||
call_args = self.image_client.update_image.call_args
|
||||
if call_args:
|
||||
args, kwargs = call_args
|
||||
_args, kwargs = call_args
|
||||
self.assertNotIn('owner_id', kwargs)
|
||||
|
||||
def test_image_set_options(self):
|
||||
|
||||
@@ -519,7 +519,7 @@ class TestUnsetAddressGroup(TestAddressGroup):
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.network_client.remove_addresses_from_address_group.assert_called_once_with( # noqa: E501
|
||||
self.network_client.remove_addresses_from_address_group.assert_called_once_with(
|
||||
self._address_group, ['10.0.0.2/32']
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@@ -539,7 +539,7 @@ class TestUnsetAddressGroup(TestAddressGroup):
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.network_client.remove_addresses_from_address_group.assert_called_once_with( # noqa: E501
|
||||
self.network_client.remove_addresses_from_address_group.assert_called_once_with(
|
||||
self._address_group, ['10.0.0.2/32', '2001::/16']
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
@@ -425,7 +425,8 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork):
|
||||
'Floating Network',
|
||||
'Project',
|
||||
)
|
||||
columns_long = columns + (
|
||||
columns_long = (
|
||||
*columns,
|
||||
'Router',
|
||||
'Status',
|
||||
'Description',
|
||||
|
||||
@@ -39,14 +39,14 @@ class TestFloatingIPPortForwarding(network_fakes.TestNetworkV2):
|
||||
class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.new_port_forwarding = network_fakes.FakeFloatingIPPortForwarding.create_one_port_forwarding( # noqa: E501
|
||||
self.new_port_forwarding = network_fakes.FakeFloatingIPPortForwarding.create_one_port_forwarding(
|
||||
attrs={
|
||||
'internal_port_id': self.port.id,
|
||||
'floatingip_id': self.floating_ip.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.new_port_forwarding_with_ranges = network_fakes.FakeFloatingIPPortForwarding.create_one_port_forwarding( # noqa: E501
|
||||
self.new_port_forwarding_with_ranges = network_fakes.FakeFloatingIPPortForwarding.create_one_port_forwarding(
|
||||
use_range=True,
|
||||
attrs={
|
||||
'internal_port_id': self.port.id,
|
||||
@@ -144,15 +144,15 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.create_floating_ip_port_forwarding.assert_called_once_with( # noqa: E501
|
||||
self.network_client.create_floating_ip_port_forwarding.assert_called_once_with(
|
||||
self.new_port_forwarding.floatingip_id,
|
||||
**{
|
||||
'external_port_range': self.new_port_forwarding_with_ranges.external_port_range, # noqa: E501
|
||||
'internal_ip_address': self.new_port_forwarding_with_ranges.internal_ip_address, # noqa: E501
|
||||
'internal_port_range': self.new_port_forwarding_with_ranges.internal_port_range, # noqa: E501
|
||||
'internal_port_id': self.new_port_forwarding_with_ranges.internal_port_id, # noqa: E501
|
||||
'external_port_range': self.new_port_forwarding_with_ranges.external_port_range,
|
||||
'internal_ip_address': self.new_port_forwarding_with_ranges.internal_ip_address,
|
||||
'internal_port_range': self.new_port_forwarding_with_ranges.internal_port_range,
|
||||
'internal_port_id': self.new_port_forwarding_with_ranges.internal_port_id,
|
||||
'protocol': self.new_port_forwarding_with_ranges.protocol,
|
||||
'description': self.new_port_forwarding_with_ranges.description, # noqa: E501
|
||||
'description': self.new_port_forwarding_with_ranges.description,
|
||||
},
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
@@ -325,11 +325,11 @@ class TestCreateFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.create_floating_ip_port_forwarding.assert_called_once_with( # noqa: E501
|
||||
self.network_client.create_floating_ip_port_forwarding.assert_called_once_with(
|
||||
self.new_port_forwarding.floatingip_id,
|
||||
**{
|
||||
'external_port': self.new_port_forwarding.external_port,
|
||||
'internal_ip_address': self.new_port_forwarding.internal_ip_address, # noqa: E501
|
||||
'internal_ip_address': self.new_port_forwarding.internal_ip_address,
|
||||
'internal_port': self.new_port_forwarding.internal_port,
|
||||
'internal_port_id': self.new_port_forwarding.internal_port_id,
|
||||
'protocol': self.new_port_forwarding.protocol,
|
||||
@@ -375,7 +375,7 @@ class TestDeleteFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.delete_floating_ip_port_forwarding.assert_called_once_with( # noqa: E501
|
||||
self.network_client.delete_floating_ip_port_forwarding.assert_called_once_with(
|
||||
self.floating_ip.id,
|
||||
self._port_forwarding[0].id,
|
||||
ignore_missing=False,
|
||||
@@ -553,7 +553,7 @@ class TestSetFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
# The Port Forwarding to set.
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self._port_forwarding = network_fakes.FakeFloatingIPPortForwarding.create_one_port_forwarding( # noqa: E501
|
||||
self._port_forwarding = network_fakes.FakeFloatingIPPortForwarding.create_one_port_forwarding(
|
||||
attrs={
|
||||
'floatingip_id': self.floating_ip.id,
|
||||
}
|
||||
@@ -675,7 +675,7 @@ class TestShowFloatingIPPortForwarding(TestFloatingIPPortForwarding):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self._port_forwarding = network_fakes.FakeFloatingIPPortForwarding.create_one_port_forwarding( # noqa: E501
|
||||
self._port_forwarding = network_fakes.FakeFloatingIPPortForwarding.create_one_port_forwarding(
|
||||
attrs={
|
||||
'floatingip_id': self.floating_ip.id,
|
||||
}
|
||||
|
||||
@@ -340,8 +340,8 @@ class TestListNetworkAgent(TestNetworkAgent):
|
||||
)
|
||||
|
||||
# Add a column 'HA State' and corresponding data.
|
||||
router_agent_columns = self.columns + ('HA State',)
|
||||
router_agent_data = [d + ('',) for d in self.data]
|
||||
router_agent_columns = (*self.columns, 'HA State')
|
||||
router_agent_data = [(*d, '') for d in self.data]
|
||||
|
||||
self.assertEqual(router_agent_columns, columns)
|
||||
self.assertEqual(len(router_agent_data), len(list(data)))
|
||||
|
||||
@@ -167,7 +167,7 @@ class TestValidateAutoAllocatedTopology(TestAutoAllocatedTopology):
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
_columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.validate_auto_allocated_topology.assert_called_with(
|
||||
None
|
||||
@@ -185,7 +185,7 @@ class TestValidateAutoAllocatedTopology(TestAutoAllocatedTopology):
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
_columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.validate_auto_allocated_topology.assert_called_with(
|
||||
self.project.id
|
||||
@@ -206,7 +206,7 @@ class TestValidateAutoAllocatedTopology(TestAutoAllocatedTopology):
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
_columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.validate_auto_allocated_topology.assert_called_with(
|
||||
self.project.id
|
||||
|
||||
@@ -71,7 +71,7 @@ class TestAddNetworkFlavorToProfile(TestNetworkFlavor):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.associate_flavor_with_service_profile.assert_called_once_with( # noqa: E501
|
||||
self.network_client.associate_flavor_with_service_profile.assert_called_once_with(
|
||||
self.network_flavor, self.service_profile
|
||||
)
|
||||
|
||||
@@ -377,7 +377,7 @@ class TestRemoveNetworkFlavorFromProfile(TestNetworkFlavor):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.disassociate_flavor_from_service_profile.assert_called_once_with( # noqa: E501
|
||||
self.network_client.disassociate_flavor_from_service_profile.assert_called_once_with(
|
||||
self.network_flavor, self.service_profile
|
||||
)
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ class TestCreateNetworkQosRuleMinimumPacketRate(TestNetworkQosRule):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.create_qos_minimum_packet_rate_rule.assert_called_once_with( # noqa: E501
|
||||
self.network_client.create_qos_minimum_packet_rate_rule.assert_called_once_with(
|
||||
self.qos_policy.id,
|
||||
**{
|
||||
'min_kpps': self.new_rule.min_kpps,
|
||||
@@ -613,7 +613,7 @@ class TestDeleteNetworkQosRuleMinimumPacketRate(TestNetworkQosRule):
|
||||
self.network_client.find_qos_policy.assert_called_once_with(
|
||||
self.qos_policy.id, ignore_missing=False
|
||||
)
|
||||
self.network_client.delete_qos_minimum_packet_rate_rule.assert_called_once_with( # noqa: E501
|
||||
self.network_client.delete_qos_minimum_packet_rate_rule.assert_called_once_with(
|
||||
self.new_rule.id, self.qos_policy.id
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
@@ -224,7 +224,7 @@ class TestCreateNetworkRBAC(TestNetworkRBAC):
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
_columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network_client.create_rbac_policy.assert_called_with(
|
||||
**{
|
||||
|
||||
@@ -250,7 +250,7 @@ class TestListNetworkSegment(TestNetworkSegment):
|
||||
'Network Type',
|
||||
'Segment',
|
||||
)
|
||||
columns_long = columns + ('Physical Network',)
|
||||
columns_long = (*columns, 'Physical Network')
|
||||
|
||||
data = []
|
||||
for _network_segment in _network_segments:
|
||||
|
||||
@@ -333,7 +333,7 @@ class TestCreateNetworkSegmentRange(TestNetworkSegmentRange):
|
||||
'shared': self._network_segment_range.shared,
|
||||
'project_id': mock.ANY,
|
||||
'network_type': self._network_segment_range.network_type,
|
||||
'physical_network': self._network_segment_range.physical_network, # noqa: E501
|
||||
'physical_network': self._network_segment_range.physical_network,
|
||||
'minimum': self._network_segment_range.minimum,
|
||||
'maximum': self._network_segment_range.maximum,
|
||||
'name': self._network_segment_range.name,
|
||||
@@ -450,10 +450,7 @@ class TestListNetworkSegmentRange(TestNetworkSegmentRange):
|
||||
'Minimum ID',
|
||||
'Maximum ID',
|
||||
)
|
||||
columns_long = columns + (
|
||||
'Used',
|
||||
'Available',
|
||||
)
|
||||
columns_long = (*columns, 'Used', 'Available')
|
||||
|
||||
data = []
|
||||
for _network_segment_range in _network_segment_ranges:
|
||||
@@ -544,11 +541,11 @@ class TestSetNetworkSegmentRange(TestNetworkSegmentRange):
|
||||
# The network segment range updated.
|
||||
minimum_updated = _network_segment_range.minimum - 5
|
||||
maximum_updated = _network_segment_range.maximum + 5
|
||||
available_updated = (
|
||||
list(range(minimum_updated, 104))
|
||||
+ [105]
|
||||
+ list(range(107, maximum_updated + 1))
|
||||
)
|
||||
available_updated = [
|
||||
*list(range(minimum_updated, 104)),
|
||||
105,
|
||||
*list(range(107, maximum_updated + 1)),
|
||||
]
|
||||
_network_segment_range_updated = (
|
||||
network_fakes.create_one_network_segment_range(
|
||||
attrs={
|
||||
|
||||
@@ -468,7 +468,7 @@ class TestListNetworkTrunk(TestNetworkTrunk):
|
||||
)
|
||||
|
||||
columns = ('ID', 'Name', 'Parent Port', 'Description')
|
||||
columns_long = columns + ('Status', 'State', 'Created At', 'Updated At')
|
||||
columns_long = (*columns, 'Status', 'State', 'Created At', 'Updated At')
|
||||
data = []
|
||||
for t in new_trunks:
|
||||
data.append((t['id'], t['name'], t['port_id'], t['description']))
|
||||
|
||||
@@ -711,17 +711,14 @@ class TestListRouter(TestRouter):
|
||||
'Distributed',
|
||||
'HA',
|
||||
)
|
||||
columns_long = columns + (
|
||||
columns_long = (
|
||||
*columns,
|
||||
'Routes',
|
||||
'External gateway info',
|
||||
'Availability zones',
|
||||
'Tags',
|
||||
)
|
||||
columns_long_no_az = columns + (
|
||||
'Routes',
|
||||
'External gateway info',
|
||||
'Tags',
|
||||
)
|
||||
columns_long_no_az = (*columns, 'Routes', 'External gateway info', 'Tags')
|
||||
|
||||
data = []
|
||||
for r in routers:
|
||||
@@ -824,7 +821,7 @@ class TestListRouter(TestRouter):
|
||||
with mock.patch.object(
|
||||
self.network_client, "routers", return_value=_routers
|
||||
):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertNotIn("is_distributed", columns)
|
||||
self.assertNotIn("is_ha", columns)
|
||||
@@ -1900,7 +1897,7 @@ class TestShowRouter(TestRouter):
|
||||
with mock.patch.object(
|
||||
self.network_client, "find_router", return_value=_router
|
||||
):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
columns, _data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.assertNotIn("is_distributed", columns)
|
||||
self.assertNotIn("is_ha", columns)
|
||||
|
||||
@@ -411,7 +411,8 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
||||
'Direction',
|
||||
'Remote Security Group',
|
||||
)
|
||||
expected_columns_no_group = expected_columns_with_group + (
|
||||
expected_columns_no_group = (
|
||||
*expected_columns_with_group,
|
||||
'Security Group',
|
||||
)
|
||||
|
||||
@@ -429,7 +430,8 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
||||
rule['port_range'],
|
||||
rule['remote_security_group'],
|
||||
)
|
||||
expected_rule_no_group = expected_rule_with_group + (
|
||||
expected_rule_no_group = (
|
||||
*expected_rule_with_group,
|
||||
_security_group_rule['parent_group_id'],
|
||||
)
|
||||
expected_data_with_group.append(expected_rule_with_group)
|
||||
|
||||
@@ -798,7 +798,8 @@ class TestListSubnet(TestSubnet):
|
||||
'Network',
|
||||
'Subnet',
|
||||
)
|
||||
columns_long = columns + (
|
||||
columns_long = (
|
||||
*columns,
|
||||
'Project',
|
||||
'DHCP',
|
||||
'Name Servers',
|
||||
|
||||
@@ -471,7 +471,8 @@ class TestListSubnetPool(TestSubnetPool):
|
||||
'Name',
|
||||
'Prefixes',
|
||||
)
|
||||
columns_long = columns + (
|
||||
columns_long = (
|
||||
*columns,
|
||||
'Default Prefix Length',
|
||||
'Address Scope',
|
||||
'Default Subnet Pool',
|
||||
|
||||
@@ -220,11 +220,7 @@ class TestBackupList(volume_fakes.TestVolume):
|
||||
'Incremental',
|
||||
'Created At',
|
||||
)
|
||||
columns_long = columns + (
|
||||
'Availability Zone',
|
||||
'Volume',
|
||||
'Container',
|
||||
)
|
||||
columns_long = (*columns, 'Availability Zone', 'Volume', 'Container')
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@@ -297,7 +297,8 @@ class TestVolumeSnapshotList(volume_fakes.TestVolume):
|
||||
self.project_mock.get.return_value = self.project
|
||||
|
||||
self.columns = ("ID", "Name", "Description", "Status", "Size")
|
||||
self.columns_long = self.columns + (
|
||||
self.columns_long = (
|
||||
*self.columns,
|
||||
"Created At",
|
||||
"Volume",
|
||||
"Properties",
|
||||
|
||||
@@ -332,7 +332,7 @@ class TestTypeList(TestType):
|
||||
"Name",
|
||||
"Is Public",
|
||||
]
|
||||
columns_long = columns + ["Description"]
|
||||
columns_long = [*columns, "Description"]
|
||||
data_with_default_type = [(volume_types[0].id, volume_types[0].name, True)]
|
||||
data = []
|
||||
for t in volume_types:
|
||||
@@ -436,9 +436,7 @@ class TestTypeList(TestType):
|
||||
'key_size': None,
|
||||
'control_location': 'front-end',
|
||||
}
|
||||
encryption_columns = self.columns + [
|
||||
"Encryption",
|
||||
]
|
||||
encryption_columns = [*self.columns, "Encryption"]
|
||||
encryption_data = []
|
||||
encryption_data.append(
|
||||
(
|
||||
|
||||
@@ -319,11 +319,7 @@ class TestBackupList(volume_fakes.TestVolume):
|
||||
'Incremental',
|
||||
'Created At',
|
||||
)
|
||||
columns_long = columns + (
|
||||
'Availability Zone',
|
||||
'Volume',
|
||||
'Container',
|
||||
)
|
||||
columns_long = (*columns, 'Availability Zone', 'Volume', 'Container')
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@@ -340,7 +340,8 @@ class TestVolumeSnapshotList(volume_fakes.TestVolume):
|
||||
self.project_mock.get.return_value = self.project
|
||||
|
||||
self.columns = ("ID", "Name", "Description", "Status", "Size")
|
||||
self.columns_long = self.columns + (
|
||||
self.columns_long = (
|
||||
*self.columns,
|
||||
"Created At",
|
||||
"Volume",
|
||||
"Properties",
|
||||
|
||||
@@ -331,7 +331,7 @@ class TestTypeList(TestType):
|
||||
"Name",
|
||||
"Is Public",
|
||||
]
|
||||
columns_long = columns + ["Description", "Properties"]
|
||||
columns_long = [*columns, "Description", "Properties"]
|
||||
data_with_default_type = [(volume_types[0].id, volume_types[0].name, True)]
|
||||
data = []
|
||||
for t in volume_types:
|
||||
@@ -509,9 +509,7 @@ class TestTypeList(TestType):
|
||||
'key_size': None,
|
||||
'control_location': 'front-end',
|
||||
}
|
||||
encryption_columns = self.columns + [
|
||||
"Encryption",
|
||||
]
|
||||
encryption_columns = [*self.columns, "Encryption"]
|
||||
encryption_data = []
|
||||
encryption_data.append(
|
||||
(
|
||||
|
||||
@@ -555,7 +555,7 @@ class ListVolume(command.Lister):
|
||||
compute_client = self.app.client_manager.compute
|
||||
for s in compute_client.servers():
|
||||
server_cache[s.id] = s
|
||||
except sdk_exceptions.SDKException: # noqa: S110
|
||||
except sdk_exceptions.SDKException:
|
||||
# Just forget it if there's any trouble
|
||||
pass
|
||||
AttachmentsColumnWithCache = functools.partial(
|
||||
|
||||
@@ -706,7 +706,7 @@ class ListVolume(command.Lister):
|
||||
compute_client = self.app.client_manager.compute
|
||||
for s in compute_client.servers():
|
||||
server_cache[s.id] = s
|
||||
except sdk_exceptions.SDKException: # noqa: S110
|
||||
except sdk_exceptions.SDKException:
|
||||
# Just forget it if there's any trouble
|
||||
pass
|
||||
AttachmentsColumnWithCache = functools.partial(
|
||||
|
||||
@@ -753,7 +753,14 @@ quote-style = "preserve"
|
||||
docstring-code-format = true
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E4", "E5", "E7", "E9", "F", "G", "S", "UP"]
|
||||
select = ["E4", "E5", "E7", "E9", "F", "G", "RUF", "S", "UP"]
|
||||
ignore = [
|
||||
# the following are ignored because they don't provide enough value for the
|
||||
# changes required
|
||||
"RUF012", # Mutable default value for class attribute
|
||||
]
|
||||
# don't remove hacking (H) or openstackclient (O) checks
|
||||
external = ["H", "O"]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"openstackclient/tests/*" = ["E501", "S"]
|
||||
|
||||
Reference in New Issue
Block a user