Skip to content

Commit 7f41e11

Browse files
linting
1 parent 5f241ce commit 7f41e11

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

core/testcontainers/compose/compose.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ def docker_compose_command(self) -> list[str]:
247247

248248
@cached_property
249249
def compose_command_property(self) -> list[str]:
250-
docker_compose_cmd = [self.docker_command_path, "compose"] if self.docker_command_path else ["docker", "compose"]
250+
docker_compose_cmd = (
251+
[self.docker_command_path, "compose"] if self.docker_command_path else ["docker", "compose"]
252+
)
251253
if self.compose_file_name:
252254
for file in self.compose_file_name:
253255
docker_compose_cmd += ["-f", file]

core/testcontainers/core/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from testcontainers.core.network import Network
2121
from testcontainers.core.utils import is_arm, setup_logger
2222
from testcontainers.core.wait_strategies import LogMessageWaitStrategy
23-
from testcontainers.core.waiting_utils import WaitStrategy, wait_container_is_ready
23+
from testcontainers.core.waiting_utils import WaitStrategy
2424

2525
if TYPE_CHECKING:
2626
from docker.models.containers import Container

core/testcontainers/core/wait_strategies.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
import time
3232
from datetime import timedelta
3333
from pathlib import Path
34-
from typing import Any, Callable, Optional, TYPE_CHECKING, Union
34+
from typing import TYPE_CHECKING, Any, Callable, Optional, Union, cast
3535
from urllib.error import HTTPError, URLError
3636
from urllib.request import Request, urlopen
3737

3838
from typing_extensions import Self
3939

4040
from testcontainers.compose import DockerCompose
4141
from testcontainers.core.utils import setup_logger
42+
4243
# Import base classes from waiting_utils to make them available for tests
4344
from testcontainers.core.waiting_utils import WaitStrategy, WaitStrategyTarget
4445

@@ -655,9 +656,10 @@ class ContainerStatusWaitStrategy(WaitStrategy):
655656
dead
656657
https://docs.docker.com/reference/cli/docker/container/ls/#status
657658
"""
658-
CONTINUE_STATUSES = {"created", "restarting"}
659659

660-
def __init__(self):
660+
CONTINUE_STATUSES = frozenset(("created", "restarting"))
661+
662+
def __init__(self) -> None:
661663
super().__init__()
662664

663665
def wait_until_ready(self, container: WaitStrategyTarget) -> None:
@@ -671,7 +673,11 @@ def running(status: str) -> bool:
671673
logger.debug("status is now running")
672674
return True
673675
if status in ContainerStatusWaitStrategy.CONTINUE_STATUSES:
674-
logger.debug("status is %s, which is valid for continuing (%s)", status, ContainerStatusWaitStrategy.CONTINUE_STATUSES)
676+
logger.debug(
677+
"status is %s, which is valid for continuing (%s)",
678+
status,
679+
ContainerStatusWaitStrategy.CONTINUE_STATUSES,
680+
)
675681
return False
676682
raise StopIteration(f"container status not valid for continuing: {status}")
677683

@@ -689,7 +695,7 @@ def _get_status_tc_container(container: "DockerContainer") -> str:
689695
logger.debug("fetching status of container %s", container)
690696
wrapped = container.get_wrapped_container()
691697
wrapped.reload()
692-
return wrapped.status
698+
return cast("str", wrapped.status)
693699

694700
@staticmethod
695701
def _get_status_compose_container(container: DockerCompose) -> str:

core/testcontainers/core/waiting_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def wait_until_ready(self, container: WaitStrategyTarget) -> None:
103103
"""Wait until the container is ready."""
104104
pass
105105

106-
def _poll(self, check: Callable[[], bool], transient_exceptions: list[type[Exception]] = None) -> bool:
106+
def _poll(self, check: Callable[[], bool], transient_exceptions: Optional[list[type[Exception]]] = None) -> bool:
107107
if not transient_exceptions:
108108
all_te_types = self._transient_exceptions
109109
else:

0 commit comments

Comments
 (0)