diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 786c26378d..14bfc2b85f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: mixed-line-ending @@ -15,7 +15,7 @@ repos: files: .*\.(yaml|yml)$ args: ['--unsafe'] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.2 + rev: v0.11.2 hooks: - id: ruff args: ['--fix', '--unsafe-fixes'] diff --git a/examples/object_api.py b/examples/object_api.py index 4ff245d4ce..5917d35fa6 100755 --- a/examples/object_api.py +++ b/examples/object_api.py @@ -94,7 +94,7 @@ def run(opts): c_list = obj_api.container_list() print("Name\tCount\tBytes") for c in c_list: - print("%s\t%d\t%d" % (c['name'], c['count'], c['bytes'])) + print(f"{c['name']}\t{c['count']}\t{c['bytes']}") if len(c_list) > 0: # See what is in the first container diff --git a/examples/osc-lib.py b/examples/osc-lib.py index 6bd0347ac7..fb8ea2dc3a 100755 --- a/examples/osc-lib.py +++ b/examples/osc-lib.py @@ -87,7 +87,7 @@ def run(opts): c_list = client_manager.object_store.container_list() print("Name\tCount\tBytes") for c in c_list: - print("%s\t%d\t%d" % (c['name'], c['count'], c['bytes'])) + print(f"{c['name']}\t{c['count']}\t{c['bytes']}") if len(c_list) > 0: # See what is in the first container diff --git a/openstackclient/network/utils.py b/openstackclient/network/utils.py index 9cb3e1a368..648c9092a9 100644 --- a/openstackclient/network/utils.py +++ b/openstackclient/network/utils.py @@ -23,7 +23,7 @@ def transform_compute_security_group_rule(sg_rule): from_port = info.pop('from_port') to_port = info.pop('to_port') if isinstance(from_port, int) and isinstance(to_port, int): - port_range = {'port_range': "%u:%u" % (from_port, to_port)} + port_range = {'port_range': f"{from_port}:{to_port}"} elif from_port is None and to_port is None: port_range = {'port_range': ""} else: diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py index ce78131853..9f99bb5dde 100644 --- a/openstackclient/network/v2/router.py +++ b/openstackclient/network/v2/router.py @@ -1270,8 +1270,7 @@ class AddGatewayToRouter(command.ShowOne): parser.add_argument( metavar="", help=_( - "External Network to a attach a router gateway to (name or " - "ID)" + "External Network to a attach a router gateway to (name or ID)" ), dest='external_gateways', # The argument is stored in a list in order to reuse the @@ -1338,8 +1337,7 @@ class RemoveGatewayFromRouter(command.ShowOne): parser.add_argument( metavar="", help=_( - "External Network to remove a router gateway from (name or " - "ID)" + "External Network to remove a router gateway from (name or ID)" ), dest='external_gateways', # The argument is stored in a list in order to reuse the diff --git a/openstackclient/tests/functional/identity/v3/test_idp.py b/openstackclient/tests/functional/identity/v3/test_idp.py index 11275795b2..c9ef01d0f1 100644 --- a/openstackclient/tests/functional/identity/v3/test_idp.py +++ b/openstackclient/tests/functional/identity/v3/test_idp.py @@ -54,13 +54,9 @@ class IdentityProviderTests(common.IdentityTests): identity_provider = self._create_dummy_idp(add_clean_up=True) new_remoteid = data_utils.rand_name('newRemoteId') raw_output = self.openstack( - 'identity provider set ' - '%(identity-provider)s ' - '--remote-id %(remote-id)s ' - % { - 'identity-provider': identity_provider, - 'remote-id': new_remoteid, - } + f'identity provider set ' + f'{identity_provider} ' + f'--remote-id {new_remoteid}' ) self.assertEqual(0, len(raw_output)) raw_output = self.openstack( diff --git a/openstackclient/tests/functional/identity/v3/test_service_provider.py b/openstackclient/tests/functional/identity/v3/test_service_provider.py index 2f941d5e87..330f938c8b 100644 --- a/openstackclient/tests/functional/identity/v3/test_service_provider.py +++ b/openstackclient/tests/functional/identity/v3/test_service_provider.py @@ -52,13 +52,9 @@ class ServiceProviderTests(common.IdentityTests): service_provider = self._create_dummy_sp(add_clean_up=True) new_description = data_utils.rand_name('newDescription') raw_output = self.openstack( - 'service provider set ' - '%(service-provider)s ' - '--description %(description)s ' - % { - 'service-provider': service_provider, - 'description': new_description, - } + f'service provider set ' + f'{service_provider} ' + f'--description {new_description}' ) updated_value = self.parse_show_as_object(raw_output) self.assertEqual(new_description, updated_value.get('description'))