11
11
# License for the specific language governing permissions and limitations
12
12
# under the License.
13
13
import uuid
14
- from typing import Optional
14
+ from typing import Any , Optional
15
15
16
16
from testcontainers .core .docker_client import DockerClient
17
17
@@ -21,12 +21,14 @@ class Network:
21
21
Network context manager for programmatically connecting containers.
22
22
"""
23
23
24
- def __init__ (self , docker_client_kw : Optional [dict ] = None , docker_network_kw : Optional [dict ] = None ) -> None :
24
+ def __init__ (
25
+ self , docker_client_kw : Optional [dict [str , Any ]] = None , docker_network_kw : Optional [dict [str , Any ]] = None
26
+ ):
25
27
self .name = str (uuid .uuid4 ())
26
28
self ._docker = DockerClient (** (docker_client_kw or {}))
27
29
self ._docker_network_kw = docker_network_kw or {}
28
30
29
- def connect (self , container_id : str , network_aliases : Optional [list ] = None ):
31
+ def connect (self , container_id : str , network_aliases : Optional [list [ str ]] = None ) -> None :
30
32
self ._network .connect (container_id , aliases = network_aliases )
31
33
32
34
def remove (self ) -> None :
@@ -40,5 +42,5 @@ def create(self) -> "Network":
40
42
def __enter__ (self ) -> "Network" :
41
43
return self .create ()
42
44
43
- def __exit__ (self , exc_type , exc_val , exc_tb ) -> None :
45
+ def __exit__ (self , exc_type , exc_val , exc_tb ) -> None : # type: ignore[no-untyped-def]
44
46
self .remove ()
0 commit comments