Skip to content

Commit a46f611

Browse files
fix mypy issues
1 parent cd2fa2d commit a46f611

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

core/testcontainers/compose/compose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _ignore_properties(cls: type[_IPT], dict_: Any) -> _IPT:
3030
raise TypeError(f"Expected a dataclass type, got {cls}")
3131
class_fields = {f.name for f in fields(cls)}
3232
filtered = {k: v for k, v in dict_.items() if k in class_fields}
33-
return cast("_IPT", cls(**filtered))
33+
return cls(**filtered)
3434

3535

3636
@dataclass

core/testcontainers/core/waiting_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from typing import Any, Callable, Optional, Protocol, TypeVar, Union, cast
2121

2222
import wrapt
23+
from paramiko.packet import first_arg
2324
from typing_extensions import Self
2425

2526
from testcontainers.core.config import testcontainers_config
@@ -161,7 +162,7 @@ def check_http(container):
161162
)
162163

163164
class LegacyWaitStrategy(WaitStrategy):
164-
def __init__(self, func: Callable[..., Any], instance: Any, args: list[Any], kwargs: dict[str, Any]):
165+
def __init__(self, func: Callable[..., Any], instance: Any, args: tuple[Any], kwargs: dict[str, Any]):
165166
super().__init__()
166167
self.func = func
167168
self.instance = instance
@@ -197,12 +198,16 @@ def wait_until_ready(self, container: WaitStrategyTarget) -> Any:
197198
logger.debug(f"Connection attempt failed: {e!s}")
198199
time.sleep(self._poll_interval)
199200

200-
@wrapt.decorator # type: ignore[misc]
201-
def wrapper(wrapped: Callable[..., Any], instance: Any, args: list[Any], kwargs: dict[str, Any]) -> Any:
201+
@wrapt.decorator
202+
def wrapper(wrapped: Callable[..., Any], instance: Any, args: tuple[Any], kwargs: dict[str, Any]) -> Any:
202203
# Use the LegacyWaitStrategy to handle retries with proper timeout
203204
strategy = LegacyWaitStrategy(wrapped, instance, args, kwargs)
204205
# For backwards compatibility, assume the instance is the container
205-
container = instance if hasattr(instance, "get_container_host_ip") else args[0] if args else None
206+
try:
207+
first_arg = args[0]
208+
except IndexError:
209+
first_arg = None
210+
container = instance if hasattr(instance, "get_container_host_ip") else first_arg
206211
if container:
207212
return strategy.wait_until_ready(container)
208213
else:

core/tests/test_network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ def test_network_has_labels():
9090
try:
9191
network.create()
9292
network = network._docker.client.networks.get(network_id=network.id)
93-
assert LABEL_SESSION_ID in network.attrs.get("Labels") # type: ignore[attr-defined]
93+
assert LABEL_SESSION_ID in network.attrs.get("Labels")
9494
finally:
9595
network.remove()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ keep-runtime-typing = true
323323
strict = true
324324

325325
[tool.mypy]
326-
python_version = "3.9"
326+
python_version = "3.10"
327327
namespace_packages = true
328328
explicit_package_bases = true
329329
pretty = true

0 commit comments

Comments
 (0)