Skip to content

Improve type hints #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions umsgpack/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
from typing import Any
from typing import Any, Callable, Type, TypeVar

try:
from typing import Protocol
except ImportError:
_SupportsRead = Any
_SupportsWrite = Any
else:
class _SupportsRead(Protocol):
def read(self, __size: int) -> bytes: ...

class _SupportsWrite(Protocol):
def write(self, __data: bytes) -> Any: ...

_T = TypeVar("_T")

__version__: str

version: tuple[int, int, int]

def pack(obj, fp, **options) -> None: ...
def packb(obj, **options) -> bytes: ...
def dump(obj, fp, **options) -> None: ...
def dumps(obj, **options) -> bytes: ...
def pack(obj: Any, fp: _SupportsWrite, **options: Any) -> None: ...
def packb(obj: Any, **options: Any) -> bytes: ...
def dump(obj: Any, fp: _SupportsWrite, **options: Any) -> None: ...
def dumps(obj: Any, **options: Any) -> bytes: ...

def unpackb(s: bytes | bytearray, **options) -> Any: ...
def unpack(fp, **options) -> Any: ...
def loads(s: bytes | bytearray, **options) -> Any: ...
def load(fp, **options) -> Any: ...
def unpackb(s: bytes | bytearray, **options: Any) -> Any: ...
def unpack(fp: _SupportsRead, **options: Any) -> Any: ...
def loads(s: bytes | bytearray, **options: Any) -> Any: ...
def load(fp: _SupportsRead, **options: Any) -> Any: ...

class Ext:
type: int
data: bytes
def __init__(self, type: int, data: bytes) -> None: ...
def __eq__(self, other) -> bool: ...
def __ne__(self, other) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...

class InvalidString(bytes): ...

def ext_serializable(ext_type: int): ...
def ext_serializable(ext_type: int) -> Callable[[Type[_T]], Type[_T]]: ...

class PackException(Exception): ...
class UnpackException(Exception): ...
Expand Down