Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
XFY9326 committed Feb 26, 2024
1 parent 1d6fc0a commit 0ead387
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/xiaomi_ndef/handoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions src/xiaomi_ndef/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 0ead387

Please sign in to comment.