Skip to content

Commit

Permalink
Broaden method type definition for preconf orjson converter.
Browse files Browse the repository at this point in the history
`bytes` is not the only input type `orjson.loads` allows.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
  • Loading branch information
PIG208 committed Jul 28, 2023
1 parent 4052f68 commit 0282517
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cattrs/preconf/orjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from base64 import b85decode, b85encode
from datetime import datetime
from enum import Enum
from typing import Any, Type, TypeVar
from typing import Any, Type, TypeVar, Union

from orjson import dumps, loads

Expand All @@ -17,7 +17,7 @@ class OrjsonConverter(Converter):
def dumps(self, obj: Any, unstructure_as: Any = None, **kwargs: Any) -> bytes:
return dumps(self.unstructure(obj, unstructure_as=unstructure_as), **kwargs)

def loads(self, data: bytes, cl: Type[T]) -> T:
def loads(self, data: Union[bytes, bytearray, memoryview, str], cl: Type[T]) -> T:
return self.structure(loads(data), cl)


Expand Down

0 comments on commit 0282517

Please sign in to comment.