@@ -29,7 +29,7 @@ class RedisContainer(DockerContainer):
29
29
>>> with RedisContainer() as redis_container:
30
30
... redis_client = redis_container.get_client()
31
31
"""
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 :
33
33
super (RedisContainer , self ).__init__ (image , ** kwargs )
34
34
self .port_to_expose = port_to_expose
35
35
self .password = password
@@ -38,23 +38,20 @@ def __init__(self, image="redis:latest", port_to_expose=6379, password=None, **k
38
38
self .with_command (f"redis-server --requirepass { self .password } " )
39
39
40
40
@wait_container_is_ready (redis .exceptions .ConnectionError )
41
- def _connect (self ):
41
+ def _connect (self ) -> None :
42
42
client = self .get_client ()
43
43
if not client .ping ():
44
44
raise redis .exceptions .ConnectionError ("Could not connect to Redis" )
45
45
46
- def get_client (self , ** kwargs ):
47
- """get redis client
46
+ def get_client (self , ** kwargs ) -> redis .Redis :
47
+ """
48
+ Get a redis client.
48
49
49
- Parameters
50
- ----------
51
- kwargs: dict
52
- Keyword arguments passed to `redis.Redis`.
50
+ Args:
51
+ **kwargs: Keyword arguments passed to `redis.Redis`.
53
52
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.
58
55
"""
59
56
return redis .Redis (
60
57
host = self .get_container_host_ip (),
@@ -63,7 +60,7 @@ def get_client(self, **kwargs):
63
60
** kwargs ,
64
61
)
65
62
66
- def start (self ):
63
+ def start (self ) -> "RedisContainer" :
67
64
super ().start ()
68
65
self ._connect ()
69
66
return self
0 commit comments