Skip to content

Commit 391ad82

Browse files
committed
Add type annotations for redis.
1 parent 5d04bfb commit 391ad82

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

redis/testcontainers/redis/__init__.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class RedisContainer(DockerContainer):
2929
>>> with RedisContainer() as redis_container:
3030
... redis_client = redis_container.get_client()
3131
"""
32-
def __init__(self, image="redis:latest", port_to_expose=6379, password=None, **kwargs):
32+
def __init__(self, image="redis:latest", port_to_expose=6379, password=None, **kwargs) -> None:
3333
super(RedisContainer, self).__init__(image, **kwargs)
3434
self.port_to_expose = port_to_expose
3535
self.password = password
@@ -38,23 +38,20 @@ def __init__(self, image="redis:latest", port_to_expose=6379, password=None, **k
3838
self.with_command(f"redis-server --requirepass {self.password}")
3939

4040
@wait_container_is_ready(redis.exceptions.ConnectionError)
41-
def _connect(self):
41+
def _connect(self) -> None:
4242
client = self.get_client()
4343
if not client.ping():
4444
raise redis.exceptions.ConnectionError("Could not connect to Redis")
4545

46-
def get_client(self, **kwargs):
47-
"""get redis client
46+
def get_client(self, **kwargs) -> redis.Redis:
47+
"""
48+
Get a redis client.
4849
49-
Parameters
50-
----------
51-
kwargs: dict
52-
Keyword arguments passed to `redis.Redis`.
50+
Args:
51+
**kwargs: Keyword arguments passed to `redis.Redis`.
5352
54-
Returns
55-
-------
56-
client: redis.Redis
57-
Redis client to connect to the container.
53+
Returns:
54+
client: Redis client to connect to the container.
5855
"""
5956
return redis.Redis(
6057
host=self.get_container_host_ip(),
@@ -63,7 +60,7 @@ def get_client(self, **kwargs):
6360
**kwargs,
6461
)
6562

66-
def start(self):
63+
def start(self) -> "RedisContainer":
6764
super().start()
6865
self._connect()
6966
return self

0 commit comments

Comments
 (0)