Merge "Enable UP031 check"

This commit is contained in:
Zuul authored and Gerrit Code Review committed 2026-10-01 06:45:01 +00:00
commit 2921a799e1
6 files changed
+11 -19

No files matched your search

+2 -7
View File
@@ -237,9 +237,7 @@ class FileHandle:
def _get_soap_url(self, scheme, host, port):
"""Returns the IPv4/v6 compatible SOAP URL for the given host."""
if netutils.is_valid_ipv6(host):
return '%s://[%s]:%d' % (scheme, host, port)
return '%s://%s:%d' % (scheme, host, port)
return f'{scheme}://{netutils.escape_ipv6(host)}:{port}'
class FileWriteHandle(FileHandle):
@@ -570,10 +568,7 @@ class VmdkHandle(FileHandle):
urlp = urlparse.urlparse(url)
if urlp.netloc == '*':
scheme, netloc, path, params, query, fragment = urlp
if netutils.is_valid_ipv6(host):
netloc = '[%s]:%d' % (host, port)
else:
netloc = "%s:%d" % (host, port)
netloc = f"{netutils.escape_ipv6(host)}:{port}"
url = urlparse.urlunparse(
(scheme, netloc, path, params, query, fragment)
)
+1 -1
View File
@@ -296,7 +296,7 @@ class Service:
def build_base_url(protocol, host, port):
proto_str = f'{protocol}://'
host_str = netutils.escape_ipv6(host)
port_str = '' if port is None else ':%d' % port
port_str = '' if port is None else f':{port}'
return proto_str + host_str + port_str
@staticmethod
+5 -7
View File
@@ -73,8 +73,7 @@ class PBMUtilityTest(base.TestCase):
@mock.patch.object(pbm, 'get_all_profiles')
def test_get_profile_id_by_name(self, get_all_profiles):
profiles = [
self._create_profile(str(i), 'profile-%d' % i)
for i in range(0, 10)
self._create_profile(str(i), f'profile-{i}') for i in range(0, 10)
]
get_all_profiles.return_value = profiles
@@ -91,13 +90,12 @@ class PBMUtilityTest(base.TestCase):
self, get_all_profiles
):
profiles = [
self._create_profile(str(i), 'profile-%d' % i)
for i in range(0, 10)
self._create_profile(str(i), f'profile-{i}') for i in range(0, 10)
]
get_all_profiles.return_value = profiles
session = mock.Mock()
profile_id = pbm.get_profile_id_by_name(session, (f'profile-{11}'))
profile_id = pbm.get_profile_id_by_name(session, ('profile-11'))
self.assertFalse(profile_id)
get_all_profiles.assert_called_once_with(session)
@@ -125,7 +123,7 @@ class PBMUtilityTest(base.TestCase):
ds_values = []
datastores = []
for i in range(0, 10):
value = "ds-%d" % i
value = f"ds-{i}"
ds_values.append(value)
datastores.append(self._create_datastore(value))
@@ -140,7 +138,7 @@ class PBMUtilityTest(base.TestCase):
ds_values = []
datastores = []
for i in range(0, 10):
value = "ds-%d" % i
value = f"ds-{i}"
ds_values.append(value)
datastores.append(self._create_datastore(value))
+1 -1
View File
@@ -161,7 +161,7 @@ class VmdkHandleTest(base.TestCase):
lease_info.deviceUrl = [device_url_0, device_url_1]
host = '10.1.2.3'
port = 443
exp_url = 'https://%s:%d/ds1/vm1.vmdk' % (host, port)
exp_url = f'https://{host}:{port}/ds1/vm1.vmdk'
vmw_http_file = rw_handles.VmdkHandle(None, None, None, None)
url, thumbprint = vmw_http_file._find_vmdk_url(lease_info, host, port)
self.assertEqual(exp_url, url)
+2 -2
View File
@@ -575,8 +575,8 @@ class VimUtilTest(base.TestCase):
mock_propset = []
for i in range(2):
mock_obj = mock.Mock()
mock_obj.name = "test_name_%d" % i
mock_obj.val = "test_val_%d" % i
mock_obj.name = f"test_name_{i}"
mock_obj.val = f"test_val_{i}"
mock_propset.append(mock_obj)
self.assertEqual(
-1
View File
@@ -45,7 +45,6 @@ select = ["E", "F", "G", "LOG", "S", "UP"]
external = ["H"]
ignore = [
"S101", # asserts are only used for type narrowing
"UP031", # TODO(tkajinam): Remove this
]
[tool.ruff.lint.per-file-ignores]