From 92a277ff4cb5cdf6caed2d16777e6eb0e7474511 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 11 Dec 2025 02:42:46 +0900 Subject: [PATCH] ruff: Enable E5 check ... to enforce maximum line length, to keep consistent code format. Note that E501 check is disabled in test code now, until we decide how to update ~50 lines violating the limit due to too long names. Change-Id: I122c8b9035d6381dafb34438517c26b01e5201f5 Signed-off-by: Takashi Kajinami --- hacking/checks.py | 6 +++--- openstackclient/api/object_store_v1.py | 5 ++++- openstackclient/identity/common.py | 3 ++- openstackclient/identity/v3/group.py | 5 +++-- openstackclient/identity/v3/user.py | 6 ++++-- openstackclient/image/v2/metadef_properties.py | 3 ++- openstackclient/volume/v2/volume_type.py | 12 ++++++++---- openstackclient/volume/v3/volume_attachment.py | 2 +- openstackclient/volume/v3/volume_type.py | 18 ++++++++++++------ pyproject.toml | 4 ++-- 10 files changed, 41 insertions(+), 23 deletions(-) diff --git a/hacking/checks.py b/hacking/checks.py index facb0cc6ac..0eb485e7e2 100644 --- a/hacking/checks.py +++ b/hacking/checks.py @@ -69,8 +69,8 @@ def assert_no_duplicated_setup(logical_line, filename): return yield ( 0, - f"O401: client_manager.{service} mocks are already provided by " - f"the {service} service's FakeClientMixin class", + f"O401: client_manager.{service} mocks are already provided " + f"by the {service} service's FakeClientMixin class", ) @@ -89,7 +89,7 @@ def assert_use_of_client_aliases(logical_line): yield (0, f"0402: prefer {service}_client to sdk_connection.{service}") if match := re.match( - r'(self\.app\.client_manager\.(compute|network|image)+\.[a-z_]+) = mock.Mock', + r'(self\.app\.client_manager\.(compute|network|image)+\.[a-z_]+) = mock.Mock', # noqa: E501 logical_line, ): yield ( diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py index fd941e4838..933b01b836 100644 --- a/openstackclient/api/object_store_v1.py +++ b/openstackclient/api/object_store_v1.py @@ -256,7 +256,10 @@ class APIv1(api.BaseAPI): # object's name in the container. object_name_str = name if name else object - full_url = f"{urllib.parse.quote(container)}/{urllib.parse.quote(object_name_str)}" + full_url = ( + f"{urllib.parse.quote(container)}/" + f"{urllib.parse.quote(object_name_str)}" + ) with open(object, 'rb') as f: response = self.create( full_url, diff --git a/openstackclient/identity/common.py b/openstackclient/identity/common.py index c6e6cfca27..0684764706 100644 --- a/openstackclient/identity/common.py +++ b/openstackclient/identity/common.py @@ -99,7 +99,8 @@ def find_service_sdk(identity_client, name_type_or_id): if next(services, None): msg = _( - "Multiple service matches found for '%(query)s', use an ID to be more specific." + "Multiple service matches found for '%(query)s', " + "use an ID to be more specific." ) % {"query": name_type_or_id} raise exceptions.CommandError(msg) diff --git a/openstackclient/identity/v3/group.py b/openstackclient/identity/v3/group.py index 2e3d9f9b0e..a1dff6ee41 100644 --- a/openstackclient/identity/v3/group.py +++ b/openstackclient/identity/v3/group.py @@ -315,8 +315,9 @@ class ListGroup(command.Lister): parsed_args.user_domain, ) if domain: - # NOTE(0weng): The API doesn't actually support filtering additionally by domain_id, - # so this doesn't really do anything. + # NOTE(0weng): The API doesn't actually support filtering + # additionally by domain_id, so this doesn't really do + # anything. data = identity_client.user_groups(user, domain_id=domain) else: data = identity_client.user_groups(user) diff --git a/openstackclient/identity/v3/user.py b/openstackclient/identity/v3/user.py index 6b3b7217e1..c6c7590965 100644 --- a/openstackclient/identity/v3/user.py +++ b/openstackclient/identity/v3/user.py @@ -420,7 +420,8 @@ class ListUser(command.Lister): dest='is_enabled', default=None, help=_( - 'List only enabled users, does nothing with --project and --group' + 'List only enabled users, does nothing with ' + '--project and --group' ), ) parser.add_argument( @@ -429,7 +430,8 @@ class ListUser(command.Lister): dest='is_enabled', default=None, help=_( - 'List only disabled users, does nothing with --project and --group' + 'List only disabled users, does nothing with ' + '--project and --group' ), ) return parser diff --git a/openstackclient/image/v2/metadef_properties.py b/openstackclient/image/v2/metadef_properties.py index 602777331d..440d4010a1 100644 --- a/openstackclient/image/v2/metadef_properties.py +++ b/openstackclient/image/v2/metadef_properties.py @@ -127,7 +127,8 @@ class DeleteMetadefProperty(command.Command): nargs="*", help=_( "Metadef properties to delete (name) " - "(omit this argument to delete all properties in the namespace)" + "(omit this argument to delete all properties " + "in the namespace)" ), ) return parser diff --git a/openstackclient/volume/v2/volume_type.py b/openstackclient/volume/v2/volume_type.py index 9e2ac20cbf..8df39d654b 100644 --- a/openstackclient/volume/v2/volume_type.py +++ b/openstackclient/volume/v2/volume_type.py @@ -171,7 +171,8 @@ class CreateVolumeType(command.ShowOne): default=False, help=_( "Enabled replication for this volume type " - "(this is an alias for '--property replication_enabled= True') " + "(this is an alias for " + "'--property replication_enabled= True') " "(requires driver support)" ), ) @@ -181,7 +182,8 @@ class CreateVolumeType(command.ShowOne): dest='availability_zones', help=_( "Set an availability zone for this volume type " - "(this is an alias for '--property RESKEY:availability_zones:') " + "(this is an alias for " + "'--property RESKEY:availability_zones:') " "(repeat option to set multiple availability zones)" ), ) @@ -534,7 +536,8 @@ class SetVolumeType(command.Command): default=False, help=_( "Enabled replication for this volume type " - "(this is an alias for '--property replication_enabled= True') " + "(this is an alias for " + "'--property replication_enabled= True') " "(requires driver support)" ), ) @@ -544,7 +547,8 @@ class SetVolumeType(command.Command): dest='availability_zones', help=_( "Set an availability zone for this volume type " - "(this is an alias for '--property RESKEY:availability_zones:') " + "(this is an alias for " + "'--property RESKEY:availability_zones:') " "(repeat option to set multiple availability zones)" ), ) diff --git a/openstackclient/volume/v3/volume_attachment.py b/openstackclient/volume/v3/volume_attachment.py index 5773a121cc..6d36e63fbe 100644 --- a/openstackclient/volume/v3/volume_attachment.py +++ b/openstackclient/volume/v3/volume_attachment.py @@ -458,7 +458,7 @@ class ListVolumeAttachment(command.Lister): } # Update search option with `filters` # if AppendFilters.filters: - # search_opts.update(shell_utils.extract_filters(AppendFilters.filters)) + # search_opts.update(shell_utils.extract_filters(AppendFilters.filters)) # noqa: E501 # TODO(stephenfin): Implement sorting attachments = volume_client.attachments( diff --git a/openstackclient/volume/v3/volume_type.py b/openstackclient/volume/v3/volume_type.py index b5b328cb82..bf193ec60c 100644 --- a/openstackclient/volume/v3/volume_type.py +++ b/openstackclient/volume/v3/volume_type.py @@ -172,7 +172,8 @@ class CreateVolumeType(command.ShowOne): default=False, help=_( "Enabled replication for this volume type " - "(this is an alias for '--property replication_enabled= True') " + "(this is an alias for " + "'--property replication_enabled= True') " "(requires driver support)" ), ) @@ -182,7 +183,8 @@ class CreateVolumeType(command.ShowOne): dest='availability_zones', help=_( "Set an availability zone for this volume type " - "(this is an alias for '--property RESKEY:availability_zones:') " + "(this is an alias for " + "'--property RESKEY:availability_zones:') " "(repeat option to set multiple availability zones)" ), ) @@ -447,7 +449,8 @@ class ListVolumeType(command.Lister): default=False, help=_( "List only volume types with replication enabled " - "(this is an alias for '--property replication_enabled= True') " + "(this is an alias for " + "'--property replication_enabled= True') " "(supported by --os-volume-api-version 3.52 or above)" ), ) @@ -457,7 +460,8 @@ class ListVolumeType(command.Lister): dest='availability_zones', help=_( "List only volume types with this availability configured " - "(this is an alias for '--property RESKEY:availability_zones:') " + "(this is an alias for " + "'--property RESKEY:availability_zones:') " "(repeat option to filter on multiple availability zones)" ), ) @@ -616,7 +620,8 @@ class SetVolumeType(command.Command): default=False, help=_( "Enabled replication for this volume type " - "(this is an alias for '--property replication_enabled= True') " + "(this is an alias for " + "'--property replication_enabled= True') " "(requires driver support)" ), ) @@ -626,7 +631,8 @@ class SetVolumeType(command.Command): dest='availability_zones', help=_( "Set an availability zone for this volume type " - "(this is an alias for '--property RESKEY:availability_zones:') " + "(this is an alias for " + "'--property RESKEY:availability_zones:') " "(repeat option to set multiple availability zones)" ), ) diff --git a/pyproject.toml b/pyproject.toml index aeb5ab495f..566289a7f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -749,7 +749,7 @@ quote-style = "preserve" docstring-code-format = true [tool.ruff.lint] -select = ["E4", "E7", "E9", "F", "S", "UP"] +select = ["E4", "E5", "E7", "E9", "F", "S", "UP"] [tool.ruff.lint.per-file-ignores] -"openstackclient/tests/*" = ["S"] +"openstackclient/tests/*" = ["E501", "S"]