From 8bf91ece47f0da48126b5470013efff0f05a9273 Mon Sep 17 00:00:00 2001 From: Arne Zellentin Date: Fri, 17 Sep 2021 18:24:21 +0200 Subject: [PATCH] chore: lint: C0209: consider-using-f-string "Formatting a regular string which could be a f-string" --- custom_components/badconga/app/client.py | 6 +++--- custom_components/badconga/app/opcode_handlers.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/custom_components/badconga/app/client.py b/custom_components/badconga/app/client.py index 65f5e83..93fad5c 100644 --- a/custom_components/badconga/app/client.py +++ b/custom_components/badconga/app/client.py @@ -95,7 +95,7 @@ def handle_ping(self, _): def handle_user_login(self, schema): """ handle_user_login """ if schema.result != 0: - raise Exception('user login error ({})'.format(hex(schema.result))) + raise Exception(f'user login error ({ hex(schema.result) })') if schema.body.deviceId == 0: raise Exception('device not configured on this account') self.set_session( @@ -108,7 +108,7 @@ def handle_user_login(self, schema): def handle_session_login(self, schema): """ handle_session_login """ if schema.result != 0: - raise Exception('session login error ({})'.format(hex(schema.result))) + raise Exception(f'session login error ({ hex(schema.result) })') self.trigger('login') def handle_device_status(self, schema): @@ -127,7 +127,7 @@ def handle_device_status(self, schema): def handle_device_list(self, schema): """ handle_device_list """ if schema.result != 0: - raise Exception('device list error ({})'.format(hex(schema.result))) + raise Exception(f'device list error ({ hex(schema.result) })') if schema.body.deviceList.deviceId == 0: raise Exception('device not configured on this account') self.device.serial_number = schema.body.deviceList.serialNumber diff --git a/custom_components/badconga/app/opcode_handlers.py b/custom_components/badconga/app/opcode_handlers.py index eb3febe..008f670 100644 --- a/custom_components/badconga/app/opcode_handlers.py +++ b/custom_components/badconga/app/opcode_handlers.py @@ -37,7 +37,7 @@ def read_string(data): """ read_string """ (str_len,) = struct.unpack('=b', data.read(1)) if str_len: - (string,) = struct.unpack('{}s'.format(str_len), data.read(str_len)) + (string,) = struct.unpack(f'{ str_len }s', data.read(str_len)) return string.decode('utf-8') return '' @@ -69,8 +69,8 @@ def read_area_info_list(parent, data): message = parent.add() message.CopyFrom(dict_to_message(schema_pb2.AreaInfo(), (area_id, area_type))) if points: - message.x.extend(struct.unpack('{}f'.format(points), data.read(points * 4))) - message.y.extend(struct.unpack('{}f'.format(points), data.read(points * 4))) + message.x.extend(struct.unpack(f'{ points }f', data.read(points * 4))) + message.y.extend(struct.unpack(f'{ points }f', data.read(points * 4))) data.read(points * 3 * 4) # dump values def read_clean_room_info_list(parent, data):