Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
Youshin committed Aug 30, 2024
1 parent 1dee33e commit 076a6af
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 27 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/Black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Black

on: [push]
jobs:
linter_name:
name: runner / black formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rickstaa/action-black@v1
with:
black_args: ". --check"
23 changes: 0 additions & 23 deletions .github/workflows/pylint.yml

This file was deleted.

25 changes: 25 additions & 0 deletions direct_redis/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
"""
DirectRedis package for enhanced Redis interactions with automatic serialization.
This package provides the DirectRedis class, which extends the functionality of
the standard Redis client to automatically handle serialization and deserialization
of Python objects. It allows for easier storage and retrieval of complex data types
in Redis, including custom Python objects, without manual encoding and decoding.
The main class provided by this package is:
- DirectRedis: An extended Redis client with automatic serialization capabilities.
Usage:
from direct_redis import DirectRedis
# Create a DirectRedis instance
dr = DirectRedis(host='localhost', port=6379, db=0)
# Use it like a regular Redis client, but with automatic serialization
dr.set('key', {'complex': 'data'})
data = dr.get('key') # Returns the deserialized Python dictionary
This package simplifies Redis operations when working with complex Python data structures,
making it easier to integrate Redis into Python applications that deal with non-string data.
"""

from .direct_redis import DirectRedis
13 changes: 9 additions & 4 deletions direct_redis/direct_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
"""

from typing import Any, Dict, List, Optional, Union
from redis import Redis

try:
from redis import Redis
except ImportError:
raise ImportError(
"Redis is not installed. Please install it using pip install redis"
)
from direct_redis.functions import (
convert_set_type,
convert_set_mapping_dic,
Expand All @@ -26,13 +32,11 @@ class DirectRedis(Redis):

def keys(self, pattern: str = "*", **kwargs: Any) -> List[str]:
"""Get all keys matching pattern."""
# kwargs를 추가하여 variadic arguments를 처리합니다.
encoded = super().keys(pattern, **kwargs)
return [convert_get_type(key, pickle_first=False) for key in encoded or []]

def randomkey(self, **kwargs: Any) -> Optional[str]:
"""Return a random key from the keyspace."""
# kwargs를 추가하여 variadic arguments를 처리합니다.
encoded = super().randomkey(**kwargs)
return convert_get_type(encoded, pickle_first=False)

Expand Down Expand Up @@ -89,7 +93,8 @@ def hset(
return super().hset(name, key, convert_set_type(value))

def hmset(self, name: str, mapping: Dict[str, Any]) -> bool:
"""Set key to value within hash ``name`` for each corresponding key and value from the ``mapping`` dict."""
"""Set key to value within hash ``name``
for each corresponding key and value from the ``mapping`` dict."""
if not isinstance(mapping, dict):
raise ValueError("mapping must be a python dictionary")
mapping = convert_set_mapping_dic(mapping)
Expand Down

0 comments on commit 076a6af

Please sign in to comment.