__init__.pyi 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. # Copyright (c) 2021 - 2025, Ilan Schnell; All Rights Reserved
  2. #
  3. # This stub, as well as util.pyi, are tested with Python 3.10 and mypy 1.11.2
  4. from collections.abc import Iterable, Iterator, Sequence
  5. from unittest.runner import TextTestResult
  6. from typing import Any, BinaryIO, Dict, Union, overload, NamedTuple
  7. CodeDict = Dict[Any, bitarray]
  8. # Python 3.12 has abc.Buffer which should be used instead
  9. BytesLike = Union[bytes, bytearray]
  10. class BufferInfo(NamedTuple):
  11. address: int
  12. nbytes: int
  13. endian: str
  14. padbits: int
  15. alloc: int
  16. readonly: bool
  17. imported: bool
  18. exports: int
  19. class decodetree:
  20. def __init__(self, code: CodeDict) -> None: ...
  21. def complete(self) -> bool: ...
  22. def nodes(self) -> int: ...
  23. def todict(self) -> CodeDict: ...
  24. class bitarray:
  25. def __init__(self,
  26. initializer: Union[int, str, Iterable[int], None] = ...,
  27. endian: Union[str, None] = ...,
  28. buffer: Any = ...) -> None: ...
  29. def all(self) -> bool: ...
  30. def any(self) -> bool: ...
  31. def append(self, value: int) -> None: ...
  32. def buffer_info(self) -> BufferInfo: ...
  33. def bytereverse(self,
  34. start: int = ...,
  35. stop: int = ...) -> None: ...
  36. def clear(self) -> None: ...
  37. def copy(self) -> bitarray: ...
  38. def count(self,
  39. sub_bitarray: Union[bitarray, int] = ...,
  40. start: int = ...,
  41. stop: int = ...,
  42. step: int = ...) -> int: ...
  43. def encode(self, code: CodeDict, x: Iterable) -> None: ...
  44. def decode(self,
  45. code: Union[CodeDict, decodetree]) -> Iterator: ...
  46. def extend(self, x: Union[str, Iterable[int]]) -> None: ...
  47. def fill(self) -> int: ...
  48. def find(self,
  49. sub_bitarray: Union[bitarray, int],
  50. start: int = ...,
  51. stop: int = ...,
  52. right: int = ...) -> int: ...
  53. def frombytes(self, a: BytesLike) -> None: ...
  54. def fromfile(self, f: BinaryIO, n: int = ...) -> None: ...
  55. def index(self,
  56. sub_bitarray: Union[bitarray, int],
  57. start: int = ...,
  58. stop: int = ...,
  59. right: int = ...) -> int: ...
  60. def insert(self, i: int, value: int) -> None: ...
  61. def invert(self, i: int = ...) -> None: ...
  62. def search(self,
  63. sub_bitarray: Union[bitarray, int],
  64. start: int = ...,
  65. stop: int = ...,
  66. right: int = ...) -> Iterator[int]: ...
  67. def pack(self, b: BytesLike) -> None: ...
  68. def pop(self, i: int = ...) -> int: ...
  69. def remove(self, value: int) -> None: ...
  70. def reverse(self) -> None: ...
  71. def setall(self, value: int) -> None: ...
  72. def sort(self, reverse: int) -> None: ...
  73. def to01(self,
  74. group: int = ...,
  75. sep: str = ...) -> str: ...
  76. def tobytes(self) -> bytes: ...
  77. def tofile(self, f: BinaryIO) -> None: ...
  78. def tolist(self) -> list[int]: ...
  79. def unpack(self,
  80. zero: bytes = ...,
  81. one: bytes = ...) -> bytes: ...
  82. def __len__(self) -> int: ...
  83. def __iter__(self) -> Iterator[int]: ...
  84. @overload
  85. def __getitem__(self, i: int) -> int: ...
  86. @overload
  87. def __getitem__(self,
  88. s: Union[slice, bitarray, Sequence]) -> bitarray: ...
  89. @overload
  90. def __setitem__(self,
  91. i: Union[int, slice, Sequence],
  92. o: int) -> None: ...
  93. @overload
  94. def __setitem__(self,
  95. s: Union[slice, bitarray, Sequence],
  96. o: bitarray) -> None: ...
  97. def __delitem__(self,
  98. i: Union[int, slice, bitarray, Sequence]) -> None: ...
  99. def __buffer__(self, flags: int, /) -> memoryview: ...
  100. def __release_buffer__(self, buffer: memoryview, /) -> None: ...
  101. def __add__(self, other: bitarray) -> bitarray: ...
  102. def __iadd__(self, other: bitarray) -> bitarray: ...
  103. def __mul__(self, n: int) -> bitarray: ...
  104. def __imul__(self, n: int) -> bitarray: ...
  105. def __rmul__(self, n: int) -> bitarray: ...
  106. def __ge__(self, other: bitarray) -> bool: ...
  107. def __gt__(self, other: bitarray) -> bool: ...
  108. def __le__(self, other: bitarray) -> bool: ...
  109. def __lt__(self, other: bitarray) -> bool: ...
  110. def __and__(self, other: bitarray) -> bitarray: ...
  111. def __or__(self, other: bitarray) -> bitarray: ...
  112. def __xor__(self, other: bitarray) -> bitarray: ...
  113. def __iand__(self, other: bitarray) -> bitarray: ...
  114. def __ior__(self, other: bitarray) -> bitarray: ...
  115. def __ixor__(self, other: bitarray) -> bitarray: ...
  116. def __invert__(self) -> bitarray: ...
  117. def __lshift__(self, n: int) -> bitarray: ...
  118. def __rshift__(self, n: int) -> bitarray: ...
  119. def __ilshift__(self, n: int) -> bitarray: ...
  120. def __irshift__(self, n: int) -> bitarray: ...
  121. # data descriptors
  122. @property
  123. def endian(self) -> str: ...
  124. @property
  125. def nbytes(self) -> int: ...
  126. @property
  127. def padbits(self) -> int: ...
  128. @property
  129. def readonly(self) -> bool: ...
  130. class frozenbitarray(bitarray):
  131. def __hash__(self) -> int: ...
  132. __version__: str
  133. def bits2bytes(n: int) -> int: ...
  134. def get_default_endian() -> str: ...
  135. def test(verbosity: int = ...) -> TextTestResult: ...
  136. def _set_default_endian(endian: str) -> None: ...
  137. def _sysinfo(key: str) -> int: ...
  138. def _bitarray_reconstructor(cls: type,
  139. buffer: bytes,
  140. endian: str,
  141. padbits: int,
  142. readonly: int) -> bitarray: ...