@@ -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 :
0 commit comments