Skip to content

Commit 728a99e

Browse files
committed
Don't use collections.abc.Buffer (py 3.12)
1 parent 217ece3 commit 728a99e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fido2/cbor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@
3737
from __future__ import annotations
3838

3939
import struct
40-
from collections.abc import Buffer
40+
from types import UnionType
4141
from typing import Any, Callable, Mapping, Sequence
4242

4343
CborType = int | bool | str | bytes | Sequence[Any] | Mapping[Any, Any]
4444

45+
# TODO: Requires Python 3.12, replace with collections.abc.Buffer
46+
Buffer = bytes | bytearray | memoryview
47+
4548

4649
def _dump_int(data: int, mt: int = 0) -> bytes:
4750
if data < 0:
@@ -90,7 +93,7 @@ def _dump_text(data: str) -> bytes:
9093
return _dump_int(len(data_bytes), mt=3) + data_bytes
9194

9295

93-
_SERIALIZERS: Sequence[tuple[type, Callable[[Any], bytes]]] = [
96+
_SERIALIZERS: Sequence[tuple[type | UnionType, Callable[[Any], bytes]]] = [
9497
(bool, _dump_bool),
9598
(int, _dump_int),
9699
(str, _dump_text),

0 commit comments

Comments
 (0)