Skip to content

Commit 237be27

Browse files
CarliJoyalexanderankin
authored andcommitted
feat(main): enable typing for complete package
- fix all typing errors and asserts in tests - improved type hints for main methods like docker.run.
1 parent 3206f94 commit 237be27

61 files changed

Lines changed: 495 additions & 190 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ lint = [
139139
"types-paramiko>=4",
140140
"ruff",
141141
"pre-commit>=4",
142+
"types-docker>=7.1.0.20260518",
143+
"boto3-stubs-lite[boto3]",
142144
]
143145
docs = [
144146
"sphinx>=8; python_version < '3.11'",
@@ -277,15 +279,15 @@ check_untyped_defs = true
277279
disable_error_code = ["no-untyped-def"]
278280

279281
[[tool.mypy.overrides]]
280-
module = ["docker.*"]
282+
module = ["pika.*"]
281283
ignore_missing_imports = true
282284

283285
[[tool.mypy.overrides]]
284-
module = ["wrapt.*"]
286+
module = ["influxdb.*"]
285287
ignore_missing_imports = true
286288

287289
[[tool.mypy.overrides]]
288-
module = ["requests.*"]
290+
module = ["cassandra.*"]
289291
ignore_missing_imports = true
290292

291293
[[tool.mypy.overrides]]
File renamed without changes.

src/testcontainers/community/aws/aws_lambda.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Union
33

44
import httpx
5+
56
from testcontainers.community.generic.server import ServerContainer
67
from testcontainers.core.image import DockerImage
78

src/testcontainers/community/azurite/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,17 @@ def __get_local_connection_string(self) -> str:
131131
f"DefaultEndpointsProtocol=http;AccountName={self.account_name};AccountKey={self.account_key};"
132132
)
133133

134-
if self.blob_service_port in self.ports:
134+
if str(self.blob_service_port) in self.ports:
135135
connection_string += (
136136
f"BlobEndpoint=http://{host_ip}:{self.get_exposed_port(self.blob_service_port)}/{self.account_name};"
137137
)
138138

139-
if self.queue_service_port in self.ports:
139+
if str(self.queue_service_port) in self.ports:
140140
connection_string += (
141141
f"QueueEndpoint=http://{host_ip}:{self.get_exposed_port(self.queue_service_port)}/{self.account_name};"
142142
)
143143

144-
if self.table_service_port in self.ports:
144+
if str(self.table_service_port) in self.ports:
145145
connection_string += (
146146
f"TableEndpoint=http://{host_ip}:{self.get_exposed_port(self.table_service_port)}/{self.account_name};"
147147
)
@@ -206,13 +206,13 @@ def __get_external_connection_string(self) -> str:
206206
f"DefaultEndpointsProtocol=http;AccountName={self.account_name};AccountKey={self.account_key};"
207207
)
208208

209-
if self.blob_service_port in self.ports:
209+
if str(self.blob_service_port) in self.ports:
210210
connection_string += f"BlobEndpoint=http://{host_ip}:{blob_port}/{self.account_name};"
211211

212-
if self.queue_service_port in self.ports:
212+
if str(self.queue_service_port) in self.ports:
213213
connection_string += f"QueueEndpoint=http://{host_ip}:{queue_port}/{self.account_name};"
214214

215-
if self.table_service_port in self.ports:
215+
if str(self.table_service_port) in self.ports:
216216
connection_string += f"TableEndpoint=http://{host_ip}:{table_port}/{self.account_name};"
217217

218218
return connection_string

src/testcontainers/community/chroma/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import TYPE_CHECKING
22

33
from requests import ConnectionError, get
4+
45
from testcontainers.core.container import DockerContainer
56
from testcontainers.core.utils import raise_for_deprecated_parameter
67
from testcontainers.core.waiting_utils import wait_container_is_ready

src/testcontainers/community/cosmosdb/_emulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(
4040
bind_ports: bool = os.getenv("AZURE_COSMOS_EMULATOR_BIND_PORTS", "true").strip().lower() in _ENV_TRUTHY,
4141
endpoint_ports: Iterable[int] = [],
4242
**other_kwargs,
43-
):
43+
) -> None:
4444
super().__init__(image=image, **other_kwargs)
4545
self.endpoint_ports = endpoint_ports
4646
self.partition_count = partition_count

src/testcontainers/community/cosmosdb/mongodb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(
3030
"AZURE_COSMOS_EMULATOR_IMAGE", "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest"
3131
),
3232
**other_kwargs,
33-
):
33+
) -> None:
3434
super().__init__(image=image, endpoint_ports=[ENDPOINT_PORT], **other_kwargs)
3535
assert mongodb_version is not None, "A MongoDB version is required to use the MongoDB Endpoint"
3636
self.mongodb_version = mongodb_version

src/testcontainers/community/cosmosdb/nosql.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from azure.core.exceptions import ServiceRequestError
22
from azure.cosmos import CosmosClient as SyncCosmosClient
33
from azure.cosmos.aio import CosmosClient as AsyncCosmosClient
4+
45
from testcontainers.core.waiting_utils import wait_container_is_ready
56

67
from ._emulator import CosmosDBEmulatorContainer
@@ -33,7 +34,7 @@ class CosmosDBNoSQLEndpointContainer(CosmosDBEmulatorContainer):
3334
3435
"""
3536

36-
def __init__(self, **kwargs):
37+
def __init__(self, **kwargs: object) -> None:
3738
super().__init__(endpoint_ports=[NOSQL_PORT], **kwargs)
3839

3940
@property

src/testcontainers/community/elasticsearch/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ElasticSearchContainer(DockerContainer):
7272
'8.3.3'
7373
"""
7474

75-
def __init__(self, image: str = "elasticsearch", port: int = 9200, **kwargs) -> None:
75+
def __init__(self, image: str = "elasticsearch", port: int = 9200, **kwargs: object) -> None:
7676
raise_for_deprecated_parameter(kwargs, "port_to_expose", "port")
7777
super().__init__(image, _wait_strategy=HttpWaitStrategy(port), **kwargs)
7878
self.port = port

src/testcontainers/community/generic/providers/sql_connection_wait_strategy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class SqlAlchemyConnectWaitStrategy(WaitStrategy):
2020
"""Wait strategy for database connectivity testing using SQLAlchemy."""
2121

22-
def __init__(self):
22+
def __init__(self) -> None:
2323
super().__init__()
2424
self.with_transient_exceptions(TimeoutError, ConnectionError, *ADDITIONAL_TRANSIENT_ERRORS)
2525

0 commit comments

Comments
 (0)