From 0ead3874df98b199dcdd7b9e02f5c2c1790de882 Mon Sep 17 00:00:00 2001 From: XFY9326 Date: Mon, 26 Feb 2024 13:08:50 +0800 Subject: [PATCH] Update --- src/xiaomi_ndef/handoff.py | 8 ++++---- src/xiaomi_ndef/tag.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/xiaomi_ndef/handoff.py b/src/xiaomi_ndef/handoff.py index d1e35b1..950f949 100644 --- a/src/xiaomi_ndef/handoff.py +++ b/src/xiaomi_ndef/handoff.py @@ -90,13 +90,13 @@ def enum_payloads_map(self) -> OrderedDict[PayloadKey, bytes]: @staticmethod def new_payloads_map(data: Mapping[PayloadKey, bytes] | Iterable[tuple[PayloadKey, bytes]]) -> UInt8BytesMap: if isinstance(data, Mapping): - data: Mapping[PayloadKey, bytes] - return UInt8BytesMap((k.key_value, v) for k, v in data.items()) + items = data.items() elif isinstance(data, Iterable): - data: Iterable[tuple[PayloadKey, bytes]] - return UInt8BytesMap((k.key_value, v) for k, v in data) + items = data else: raise TypeError(f"Unsupported data type: {type(data)}") + items: Iterable[tuple[PayloadKey, bytes]] + return UInt8BytesMap((k.key_value, v) for k, v in items) @staticmethod def encode_payloads_map(data: OrderedDict[PayloadKey, bytes]) -> bytes: diff --git a/src/xiaomi_ndef/tag.py b/src/xiaomi_ndef/tag.py index 1227228..9b441b4 100644 --- a/src/xiaomi_ndef/tag.py +++ b/src/xiaomi_ndef/tag.py @@ -315,13 +315,13 @@ def get_app_data_value_type(app_data: bytes, action: Action, ndef_type: XiaomiNd @staticmethod def new_attributes_map(data: Mapping[DeviceAttribute, bytes] | Iterable[tuple[DeviceAttribute, bytes]]) -> UInt16BytesMap: if isinstance(data, Mapping): - data: Mapping[DeviceAttribute, bytes] - return UInt16BytesMap((k.attribute_value, v) for k, v in data.items()) + items = data.items() elif isinstance(data, Iterable): - data: Iterable[tuple[DeviceAttribute, bytes]] - return UInt16BytesMap((k.attribute_value, v) for k, v in data) + items = data else: raise TypeError(f"Unsupported data type: {type(data)}") + items: Iterable[tuple[DeviceAttribute, bytes]] + return UInt16BytesMap((k.attribute_value, v) for k, v in items) @staticmethod def decode_attributes_map(buffer: bytes) -> OrderedDict[DeviceAttribute, bytes]: