3131import time
3232from datetime import timedelta
3333from pathlib import Path
34- from typing import Any , Callable , Optional , TYPE_CHECKING , Union
34+ from typing import TYPE_CHECKING , Any , Callable , Optional , Union , cast
3535from urllib .error import HTTPError , URLError
3636from urllib .request import Request , urlopen
3737
3838from typing_extensions import Self
3939
4040from testcontainers .compose import DockerCompose
4141from testcontainers .core .utils import setup_logger
42+
4243# Import base classes from waiting_utils to make them available for tests
4344from 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 :
0 commit comments