1111# License for the specific language governing permissions and limitations
1212# under the License.
1313import uuid
14- from typing import Optional
14+ from typing import Any , Optional
1515
1616from testcontainers .core .docker_client import DockerClient
1717
@@ -21,12 +21,14 @@ class Network:
2121 Network context manager for programmatically connecting containers.
2222 """
2323
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+ ):
2527 self .name = str (uuid .uuid4 ())
2628 self ._docker = DockerClient (** (docker_client_kw or {}))
2729 self ._docker_network_kw = docker_network_kw or {}
2830
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 :
3032 self ._network .connect (container_id , aliases = network_aliases )
3133
3234 def remove (self ) -> None :
@@ -40,5 +42,5 @@ def create(self) -> "Network":
4042 def __enter__ (self ) -> "Network" :
4143 return self .create ()
4244
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]
4446 self .remove ()
0 commit comments