Skip to content

Commit 6431f47

Browse files
committed
Add type annotations for localstack.
1 parent cd92717 commit 6431f47

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

localstack/testcontainers/localstack/__init__.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,35 @@ class LocalStackContainer(DockerContainer):
3636
scan_result = dynamo_client.scan(TableName='foo')
3737
# Do something with the scan result
3838
"""
39-
EDGE_PORT = 4566
40-
IMAGE = 'localstack/localstack:0.11.4'
41-
42-
def __init__(self, image=IMAGE, **kwargs):
39+
def __init__(self, image: str = 'localstack/localstack:0.11.4', edge_port: int = 4566,
40+
**kwargs) -> None:
4341
super(LocalStackContainer, self).__init__(image, **kwargs)
44-
self.with_exposed_ports(LocalStackContainer.EDGE_PORT)
42+
self.edge_port = edge_port
43+
self.with_exposed_ports(self.edge_port)
4544

46-
def with_services(self, *services):
45+
def with_services(self, *services) -> "LocalStackContainer":
4746
"""
4847
Restrict what services to run. By default all localstack services are launched.
49-
:return: the DockerContainer to allow chaining of 'with_*' calls.
48+
49+
Args:
50+
services: Sequency of services to launch.
51+
52+
Returns:
53+
self: Container to allow chaining of 'with_*' calls.
5054
"""
5155
return self.with_env('SERVICES', ','.join(services))
5256

53-
def get_url(self):
57+
def get_url(self) -> str:
5458
"""
5559
Use this to call localstack instead of real AWS services.
5660
ex: boto3.client('lambda', endpoint_url=localstack.get_url())
5761
:return: the endpoint where localstack is reachable.
5862
"""
5963
host = self.get_container_host_ip()
60-
port = self.get_exposed_port(LocalStackContainer.EDGE_PORT)
64+
port = self.get_exposed_port(self.edge_port)
6165
return 'http://{}:{}'.format(host, port)
6266

63-
def start(self, timeout=60):
67+
def start(self, timeout: float = 60) -> "LocalStackContainer":
6468
super().start()
6569
wait_for_logs(self, r'Ready\.\n', timeout=timeout)
6670
return self

0 commit comments

Comments
 (0)