Skip to content

Commit 53321c3

Browse files
sbdchdifduyue
authored andcommitted
Add type stubs for static type checking
Type stubs for the C extension and the necessary packaging config so type checkers will find the stubs. rel: https://www.python.org/dev/peps/pep-0561/#packaging-type-information
1 parent 34ba40a commit 53321c3

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

hiredis/hiredis.pyi

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from typing import Any, Callable, Optional, Union
2+
3+
class HiredisError(Exception): ...
4+
class ProtocolError(HiredisError): ...
5+
class ReplyError(HiredisError): ...
6+
7+
class Reader:
8+
def __init__(
9+
self,
10+
protocolError: Callable[[str], Exception] = ...,
11+
replyError: Callable[[str], Exception] = ...,
12+
encoding: Optional[str] = ...,
13+
errors: Optional[str] = ...,
14+
) -> None: ...
15+
def feed(
16+
self, __buf: Union[str, bytes], __off: int = ..., __len: int = ...
17+
) -> None: ...
18+
def gets(self, __shouldDecode: bool = ...) -> Any: ...
19+
def setmaxbuf(self, __maxbuf: Optional[int]) -> None: ...
20+
def getmaxbuf(self) -> int: ...
21+
def len(self) -> int: ...
22+
def has_data(self) -> bool: ...
23+
def set_encoding(
24+
self, encoding: Optional[str] = ..., errors: Optional[str] = ...
25+
) -> None: ...

hiredis/py.typed

Whitespace-only changes.

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def version():
2727
keywords=["Redis"],
2828
license="BSD",
2929
packages=["hiredis"],
30+
package_data={"hiredis": ["py.typed"]},
3031
ext_modules=[ext],
3132
python_requires=">=3.6",
3233
classifiers=[

0 commit comments

Comments
 (0)