Skip to content

Commit 7e47c78

Browse files
committed
Add type annotations for azurite.
1 parent b4c36a1 commit 7e47c78

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

azurite/testcontainers/azurite/__init__.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# under the License.
1313
import os
1414
import socket
15+
from typing import Iterable, Optional
1516

1617
from testcontainers.core.container import DockerContainer
1718
from testcontainers.core.waiting_utils import wait_container_is_ready
@@ -48,21 +49,14 @@ class AzuriteContainer(DockerContainer):
4849
_QUEUE_SERVICE_PORT = 10_001
4950
_TABLE_SERVICE_PORT = 10_002
5051

51-
def __init__(
52-
self,
53-
image="mcr.microsoft.com/azure-storage/azurite:latest",
54-
ports_to_expose=None,
55-
**kwargs
56-
):
52+
def __init__(self, image: str = "mcr.microsoft.com/azure-storage/azurite:latest",
53+
ports_to_expose: Optional[Iterable[int]] = None, **kwargs) -> None:
5754
""" Constructs an AzuriteContainer.
5855
59-
Parameters
60-
----------
61-
image: str
62-
Expects an image with tag.
63-
ports_to_expose: List[int]
64-
Expects a list with port numbers to expose.
65-
kwargs
56+
Args:
57+
image: Expects an image with tag.
58+
ports_to_expose: List with port numbers to expose.
59+
**kwargs: Keyword arguments passed to super class.
6660
"""
6761
super().__init__(image=image, **kwargs)
6862

@@ -80,7 +74,7 @@ def __init__(
8074
self.with_env("AZURITE_ACCOUNTS",
8175
f"{self._AZURITE_ACCOUNT_NAME}:{self._AZURITE_ACCOUNT_KEY}")
8276

83-
def get_connection_string(self):
77+
def get_connection_string(self) -> str:
8478
host_ip = self.get_container_host_ip()
8579
connection_string = f"DefaultEndpointsProtocol=http;" \
8680
f"AccountName={self._AZURITE_ACCOUNT_NAME};" \
@@ -103,13 +97,13 @@ def get_connection_string(self):
10397

10498
return connection_string
10599

106-
def start(self):
100+
def start(self) -> 'AzuriteContainer':
107101
super().start()
108102
self._connect()
109103
return self
110104

111105
@wait_container_is_ready(OSError)
112-
def _connect(self):
106+
def _connect(self) -> None:
113107
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
114108
s.connect((self.get_container_host_ip(),
115109
int(self.get_exposed_port(next(iter(self.ports))))))

0 commit comments

Comments
 (0)