Skip to content

Commit 860d0f2

Browse files
fix mypy issues
1 parent cd2fa2d commit 860d0f2

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def check_http(container):
161161
)
162162

163163
class LegacyWaitStrategy(WaitStrategy):
164-
def __init__(self, func: Callable[..., Any], instance: Any, args: list[Any], kwargs: dict[str, Any]):
164+
def __init__(self, func: Callable[..., Any], instance: Any, args: tuple[Any], kwargs: dict[str, Any]):
165165
super().__init__()
166166
self.func = func
167167
self.instance = instance
@@ -197,12 +197,16 @@ def wait_until_ready(self, container: WaitStrategyTarget) -> Any:
197197
logger.debug(f"Connection attempt failed: {e!s}")
198198
time.sleep(self._poll_interval)
199199

200-
@wrapt.decorator # type: ignore[misc]
201-
def wrapper(wrapped: Callable[..., Any], instance: Any, args: list[Any], kwargs: dict[str, Any]) -> Any:
200+
@wrapt.decorator
201+
def wrapper(wrapped: Callable[..., Any], instance: Any, args: tuple[Any], kwargs: dict[str, Any]) -> Any:
202202
# Use the LegacyWaitStrategy to handle retries with proper timeout
203203
strategy = LegacyWaitStrategy(wrapped, instance, args, kwargs)
204204
# 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
205+
try:
206+
first_arg = args[0]
207+
except IndexError:
208+
first_arg = None
209+
container = instance if hasattr(instance, "get_container_host_ip") else first_arg
206210
if container:
207211
return strategy.wait_until_ready(container)
208212
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)