Skip to content

Commit

Permalink
add typings for Kombu serialization module (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcorpet authored Aug 1, 2023
1 parent 7801ddc commit 6687cf7
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions kombu-stubs/serialization.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import pickle as pickle
from collections.abc import Callable, Container, Iterable, Mapping
from typing import Any, NamedTuple

pickle_load = pickle.load

_Encoder = Callable[[Any], str]
_Decoder = Callable[[str], Any]

class codec(NamedTuple):
content_type: str
content_encoding: str
encoder: _Encoder

class SerializerRegistry:
type_to_name: dict[str, str]
name_to_type: dict[str, str]
def __init__(self) -> None: ...
def register(
self,
name: str,
encoder: _Encoder | None,
decoder: _Decoder | None,
content_type: str,
content_encoding: str = ...,
) -> None: ...
def enable(self, name: str) -> None: ...
def disable(self, name: str) -> None: ...
def unregister(self, name: str) -> None: ...
def dumps(
self, data: Any, serializer: str | None = ...
) -> tuple[str, str, str]: ...
def loads(
self,
data: bytes | str,
content_type: str,
content_encoding: str,
accept: Container[str] | None = ...,
force: bool = ...,
_trusted_content: Container[str] = ...,
) -> Any: ...

def dumps(data: Any, serializer: str | None = ...) -> tuple[str, str, str]: ...
def loads(
data: bytes | str,
content_type: str,
content_encoding: str,
accept: Container[str] | None = ...,
force: bool = ...,
_trusted_content: Container[str] = ...,
) -> Any: ...
def register(
name: str,
encoder: _Encoder | None,
decoder: _Decoder | None,
content_type: str,
content_encoding: str = ...,
) -> None: ...
def unregister(name: str) -> None: ...
def raw_encode(data: Any) -> tuple[str, str, str]: ...
def register_json() -> None: ...
def register_yaml() -> None: ...
def register_pickle() -> None: ...
def register_msgpack() -> None: ...
def enable_insecure_serializers(choices: Container[str] | None = ...) -> None: ...
def disable_insecure_serializers(allowed: Container[str] | None = ...) -> None: ...
def prepare_accept_content(
content_types: Iterable[str] | None, name_to_type: Mapping[str, str] | None = ...
) -> set[str] | None: ...

0 comments on commit 6687cf7

Please sign in to comment.