Skip to content

Commit

Permalink
Fix orjson stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatal1ty committed Oct 19, 2022
1 parent fff0032 commit b973167
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions mashumaro/mixins/orjson.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from typing import Any, Callable, Dict, TypeVar, Union
from typing import Any, Callable, Dict, Type, TypeVar, Union

import orjson

from mashumaro.core.helpers import ConfigValue as ConfigValue
from mashumaro.dialect import Dialect as Dialect
from mashumaro.helper import pass_through as pass_through
from mashumaro.mixins.dict import DataClassDictMixin as DataClassDictMixin
from mashumaro.dialect import Dialect
from mashumaro.mixins.dict import DataClassDictMixin

T = TypeVar("T", bound="DataClassORJSONMixin")

EncodedData = Union[str, bytes, bytearray]
Encoder = Callable[[Any], EncodedData]
Decoder = Callable[[EncodedData], Dict[Any, Any]]
Expand All @@ -16,23 +15,25 @@ class OrjsonDialect(Dialect):
serialization_strategy: Any

class DataClassORJSONMixin(DataClassDictMixin):
__slots__ = ()
def to_jsonb(
self,
self: T,
encoder: Encoder = orjson.dumps,
*,
orjson_options: int = ...,
**to_dict_kwargs,
) -> bytes: ...
def to_json(
self,
self: T,
encoder: Encoder = orjson.dumps,
*,
orjson_options: int = ...,
**to_dict_kwargs,
) -> bytes: ...
@classmethod
def from_json(
cls,
cls: Type[T],
data: EncodedData,
decoder: Decoder = ...,
decoder: Decoder = orjson.loads,
**from_dict_kwargs,
) -> T: ...

0 comments on commit b973167

Please sign in to comment.