Skip to content

Commit

Permalink
add .pyi files
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanschnell committed Jun 10, 2021
1 parent c38927e commit 82e9dc1
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
99 changes: 99 additions & 0 deletions bitarray/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from collections.abc import Iterable

from typing import Any, BinaryIO, Optional, Union, overload
from typing_extensions import Literal


Bool = Union[Literal[0, 1], bool]
Codedict = dict[Any, bitarray]


class decodetree:
def __init__(self, code: Codedict, /) -> None: ...
def nodes(self) -> int: ...
def todict(self) -> Codedict: ...


class bitarray:
def __init__(self, initializer: Union[int, str, Iterable, None]=0,
endian: str=..., /) -> None: ...
def all(self) -> bool: ...
def any(self) -> bool: ...
def append(self, value: Bool, /) -> None: ...
def buffer_info(self) -> tuple[int, int, str, int, int]: ...
def bytereverse(self) -> None: ...
def clear(self) -> None: ...
def copy(self) -> bitarray: ...
def count(self, value: Bool=1, start: int=0, stop: int=..., /) -> int: ...
def decode(self, code: Union[Codedict, decodetree], /) -> list: ...
def encode(self, code: Codedict, x: Iterable, /) -> None: ...
def endian(self) -> str: ...
def extend(self, x: Iterable[Bool], /) -> None: ...
def fill(self) -> int: ...
def find(self, a: Union[bitarray, Bool],
start: int=0, stop: int=..., /) -> int: ...
def frombytes(self, a: bytes, /) -> None: ...
def fromfile(self, f: BinaryIO, n: int=-1, /) -> None: ...
def index(self, a: Union[bitarray, Bool],
start: int=0, stop: int=..., /) -> int: ...
def insert(self, i: int, value: Bool, /) -> None: ...
def invert(self, i: int=...) -> None: ...
def iterdecode(self,
code: Union[Codedict, decodetree], /) -> Iterable[int]: ...
def itersearch(self, a: Union[bitarray, Bool], /) -> Iterable[int]: ...
def pack(self, b: bytes, /) -> None: ...
def pop(self, i: int=..., /) -> int: ...
def remove(self, value: Bool, /) -> None: ...
def reverse(self) -> None: ...
def search(self, a: Union[bitarray, Bool],
limit: Optional[int] = ...) -> list[int]: ...
def setall(self, value: Bool, /) -> None: ...
def sort(self, reverse: int) -> None: ...
def to01(self) -> str: ...
def tobytes(self) -> bytes: ...
def tofile(self, f: BinaryIO, /) -> None: ...
def tolist(self) -> list[int]: ...
def unpack(self, zero: bytes=..., one: bytes=...) -> bytes: ...

def __len__(self) -> int: ...
@overload
def __getitem__(self, i: int) -> int: ...
@overload
def __getitem__(self, s: slice) -> bitarray: ...
@overload
def __setitem__(self, i: Union[int, slice], o: Bool) -> None: ...
@overload
def __setitem__(self, s: slice, o: bitarray) -> None: ...
def __delitem__(self, i: Union[int, slice]) -> None: ...

def __add__(self, other: bitarray) -> bitarray: ...
def __iadd__(self, other: bitarray) -> bitarray: ...
def __mul__(self, n: int) -> bitarray: ...
def __imul__(self, n: int) -> bitarray: ...
def __rmul__(self, n: int) -> bitarray: ...

def __ge__(self, other: bitarray) -> bool: ...
def __gt__(self, other: bitarray) -> bool: ...
def __le__(self, other: bitarray) -> bool: ...
def __lt__(self, other: bitarray) -> bool: ...

def __and__(self, other: bitarray) -> bitarray: ...
def __or__(self, other: bitarray) -> bitarray: ...
def __xor__(self, other: bitarray) -> bitarray: ...
def __iand__(self, other: bitarray) -> bitarray: ...
def __ior__(self, other: bitarray) -> bitarray: ...
def __ixor__(self, other: bitarray) -> bitarray: ...
def __invert__(self) -> bitarray: ...
def __lshift__(self, n: int) -> bitarray: ...
def __rshift__(self, n: int) -> bitarray: ...
def __ilshift__(self, n: int) -> bitarray: ...
def __irshift__(self, n: int) -> bitarray: ...


class frozenbitarray(bitarray):
...


def bits2bytes(n: int, /) -> int: ...
def get_default_endian() -> str: ...
def _sysinfo() -> tuple: ...
35 changes: 35 additions & 0 deletions bitarray/util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import BinaryIO, Literal, Optional, Union, Any, AnyStr

from bitarray import bitarray


Bool = Union[Literal[0, 1], bool]


def zeros(length: int, endian: Optional[str] = ...): ...
def urandom(length: int, endian: Optional[str] = ...): ...
def pprint(a: Any, stream: BinaryIO = ...,
group: int = ...,
indent: int = ...,
width: int = ...) -> None: ...

def make_endian(a: bitarray, endian: str): ...
def rindex(a: bitarray, Value: Bool) -> int: ...
def strip(a: bitarray, mode: Optional[str] = ...) -> bitarray: ...
def count_n(a: bitarray, n: int, /) -> int: ...
def parity(a: bitarray, /) -> int: ...
def count_and(a: bitarray, b: bitarray, /) -> int: ...
def count_or(a: bitarray, b: bitarray, /) -> int: ...
def count_xor(a: bitarray, b: bitarray, /) -> int: ...
def subset(a: bitarray, b: bitarray, /) -> bool: ...
def ba2hex(a: bitarray, /) -> str: ...
def hex2ba(s: AnyStr, /, endian: str = ...): ...
def ba2base(n: int, a: bitarray, /) -> str: ...
def base2ba(n: int, s: AnyStr, /, endian: str = ...): ...
def ba2int(a: bitarray, signed: bool = ...): ...
def int2ba(i: int, /,
length: int = ..., endian: str = ..., signed: bool = ...): ...
def serialize(a: bitarray, /) -> bytes: ...
def deserialize(b: bytes, /) -> bitarray: ...
def huffman_code(freq_map: dict[Any, Union[int, float]],
endian: Optional[str] = ...) -> dict[Any, bitarray]: ...

0 comments on commit 82e9dc1

Please sign in to comment.