From e77bea44a32aa2f0758cf5684f0645903d5b4cdd Mon Sep 17 00:00:00 2001 From: Kenneth Giusti Date: Mon, 20 May 2024 13:17:15 -0400 Subject: [PATCH] fixup: correct python linter errors --- python/skupper_router/management/client.py | 3 +-- python/skupper_router_internal/management/qdrouter.py | 1 + python/skupper_router_internal/tools/display.py | 4 +--- tests/TCP_echo_client.py | 8 +++++--- tests/TCP_echo_server.py | 1 - tests/system_test.py | 3 ++- tests/system_tests_topology.py | 2 ++ tests/system_tests_topology_disposition.py | 3 +-- tests/system_tests_two_routers.py | 4 ++-- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/python/skupper_router/management/client.py b/python/skupper_router/management/client.py index 076b534fd..8415c2367 100644 --- a/python/skupper_router/management/client.py +++ b/python/skupper_router/management/client.py @@ -296,8 +296,7 @@ def query(self, type=None, attribute_names=None, offset=None, count=None): if count == len_response_results: break - if count - len_response_results < request_count: - request_count = count - len_response_results + request_count = min(request_count, count - len_response_results) offset += request_count diff --git a/python/skupper_router_internal/management/qdrouter.py b/python/skupper_router_internal/management/qdrouter.py index ae5b19d85..7ab88c865 100644 --- a/python/skupper_router_internal/management/qdrouter.py +++ b/python/skupper_router_internal/management/qdrouter.py @@ -62,6 +62,7 @@ def validate_add( super(QdSchema, self).validate_add(attributes, entities) entities.append(attributes) router_mode = router_id = listener_connector_role = listener_role = None + list_conn_entity = None for e in entities: short_type = self.short_name(e['type']) if short_type == "router": diff --git a/python/skupper_router_internal/tools/display.py b/python/skupper_router_internal/tools/display.py index 48523a00a..32107281d 100644 --- a/python/skupper_router_internal/tools/display.py +++ b/python/skupper_router_internal/tools/display.py @@ -224,9 +224,7 @@ def table(self, title, heads, rows): width = len(head) for row in rows: text = UNICODE(row[col]) - cellWidth = len(text) - if cellWidth > width: - width = cellWidth + width = max(width, len(text)) colWidth.append(width + self.tableSpacing) line = line + head if col < len(heads) - 1: diff --git a/tests/TCP_echo_client.py b/tests/TCP_echo_client.py index 0eac0ce45..e65400c5b 100755 --- a/tests/TCP_echo_client.py +++ b/tests/TCP_echo_client.py @@ -109,11 +109,13 @@ def run(self): total_sent = 0 total_rcvd = 0 + payload_out = [] + out_list_idx = 0 # current _out array being sent + out_byte_idx = 0 # next-to-send in current array + out_ready_to_send = False + if self.count > 0 and self.size > 0: # outbound payload only if count and size both greater than zero - payload_out = [] - out_list_idx = 0 # current _out array being sent - out_byte_idx = 0 # next-to-send in current array out_ready_to_send = True # Generate unique content for each message so you can tell where the message # or fragment belongs in the whole stream. Chunks look like: diff --git a/tests/TCP_echo_server.py b/tests/TCP_echo_server.py index 5da6efb04..e5716d3a0 100755 --- a/tests/TCP_echo_server.py +++ b/tests/TCP_echo_server.py @@ -83,7 +83,6 @@ def connection_made(self, transport): if self.echo_server.close_on_conn: self.logger.log(f' {self.name}: Connection from {self.peername} closing due to close_on_conn') self.transport.close() - return def connection_lost(self, exc): self.logger.log(f' {self.name}: Connection to {self.peername} lost, exception={exc}') diff --git a/tests/system_test.py b/tests/system_test.py index 8e676e84c..3bb3c2e94 100755 --- a/tests/system_test.py +++ b/tests/system_test.py @@ -259,7 +259,8 @@ def get_local_host_socket(socket_address_family='IPv4'): elif socket_address_family == 'IPv6': s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) host = '::1' - + else: + raise Exception(f"Invalid socket_address_family: {socket_address_family}") return s, host diff --git a/tests/system_tests_topology.py b/tests/system_tests_topology.py index 30bfa0d84..89ead526e 100644 --- a/tests/system_tests_topology.py +++ b/tests/system_tests_topology.py @@ -535,6 +535,8 @@ def on_message(self, event): router = 'C' elif event.receiver == self.routers['D']['mgmt_receiver']: router = 'D' + else: + raise Exception("Unexpected event receiver") # ---------------------------------------------------------------- # This is a management message. diff --git a/tests/system_tests_topology_disposition.py b/tests/system_tests_topology_disposition.py index da108607c..a7427a78b 100644 --- a/tests/system_tests_topology_disposition.py +++ b/tests/system_tests_topology_disposition.py @@ -1150,8 +1150,7 @@ def quick_print_unknown_messages(self) : count = count + 1 if first == -1 : first = i - if i > last : - last = i + last = i print(' first : %s sent : %.6lf' % (first, self.message_times[str(first)])) print(' last : %s sent : %.6lf' % (last, self.message_times[str(last)])) diff --git a/tests/system_tests_two_routers.py b/tests/system_tests_two_routers.py index 7ffcfadb3..758b5fb3c 100644 --- a/tests/system_tests_two_routers.py +++ b/tests/system_tests_two_routers.py @@ -482,9 +482,9 @@ def on_message(self, event): if event.message.properties['statusDescription'] != 'OK': error = "Expected statusDescription to be OK but instead got %s" % \ event.message.properties['statusDescription'] - elif event.message.body['adminStatus'] != self.deleted_admin_status: + else: error = "Expected adminStatus to be %s but instead got %s" % \ - (self.deleted_admin_status, event.message.properties['adminStatus']) + (self.deleted_admin_status, event.message.properties['adminStatus']) self.bail(error) elif event.receiver == self.mgmt_receiver_2: