Skip to content
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

Add pyi #6

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Generated by Cargo
# will have compiled files and executables
/target/
*.so

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# Python
.venv
.env
__pycache__
.mypy-cache
.ruff-cache

# IDE
.idea
28 changes: 25 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "redis-rs"
requires-python = ">=3.7"
requires-python = ">=3.8"
description = "Python wrapper for redis-rs"
authors = [
{ name = "Alexander Malev", email = "[email protected]" },
Expand All @@ -21,7 +21,6 @@ classifiers = [
"Framework :: AsyncIO",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -34,19 +33,42 @@ Issues = "https://github.com/aamalev/redis-rs-py/issues"
Documentation = "https://github.com/aamalev/redis-rs-py#using"
Changelog = "https://github.com/aamalev/redis-rs-py/releases"

[tool.mypy]
warn_redundant_casts = true
check_untyped_defs = true

[tool.black]
line-length = 120
target-version = [
"py38",
"py39",
"py310",
"py311",
]

[tool.ruff]
line-length = 120

[tool.hatch.envs.default]
dependencies = [
"maturin",
"mypy",
"black",
"ruff",
"isort",
]

[tool.hatch.envs.default.scripts]
build = [
"maturin develop",
]
check = [
"ruff redis_rs",
"mypy redis_rs",
"cargo clippy",
"build",
]
fmt = [
"cargo fmt",
"isort redis_rs",
"black redis_rs",
]
1 change: 1 addition & 0 deletions redis_rs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .redis_rs import *
59 changes: 59 additions & 0 deletions redis_rs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from typing import Dict, List, Literal, Optional, Union, overload

class exceptions:
class PoolError(Exception): ...
class RedisError(Exception): ...

Encoding = Union[
Literal["utf-8"],
Literal["utf8"],
Literal["int"],
Literal["float"],
]

Arg = Union[str, bytes, int, float]
Result = Union[bytes, str, int, float, dict, list]

class Client:
def status(self) -> Dict: ...
async def __aenter__(self) -> "AsyncClient": ...
async def __aexit__(self, *args, **kwargs): ...

class AsyncClient:
def status(self) -> Dict: ...
async def execute(self, *args: Arg, encoding: Optional[Encoding] = None) -> Result: ...
async def fetch_bytes(self, *args: Arg) -> bytes: ...
async def fetch_str(self, *args: Arg) -> str: ...
async def fetch_int(self, *args: Arg) -> int: ...
async def fetch_float(self, *args: Arg) -> float: ...
async def fetch_dict(self, *args: Arg, encoding: Optional[Encoding] = None) -> dict: ...
async def fetch_scores(self, *args: Arg) -> Dict[str, float]: ...
async def set(self, key: str, value: Arg): ...
async def get(self, key: str, *, encoding: Optional[Encoding] = None) -> Result: ...
async def hset(self, key: str, field: str, value: Arg): ...
async def hget(self, key: str, field: str, *, encoding: Optional[Encoding] = None) -> Result: ...
async def incr(self, key: str, delta: Union[None, int, float] = None) -> float: ...
async def lpush(self, key: str, value: Arg): ...
async def lpop(self, key: str, *, encoding: Optional[Encoding] = None) -> Result: ...
async def lrange(
self,
key: str,
start: int = 0,
stop: int = -1,
*,
encoding: Optional[Encoding] = None,
) -> List[Result]: ...
@overload
async def xadd(self, stream: str, id: str, items: Dict[str, Arg]) -> Dict: ...
@overload
async def xadd(self, stream: str, items: Dict[str, Arg]) -> Dict: ...
@overload
async def xadd(self, stream: str, *args: Arg) -> Dict: ...
async def xread(
self,
streams: Dict[str, Union[str, Literal["$"], Literal[0]]],
*,
encoding: Optional[Encoding] = None,
) -> Dict: ...

def create_client(*args: str, max_size: Optional[int] = None, cluster: Optional[bool] = None) -> Client: ...
Empty file added redis_rs/py.typed
Empty file.