|
20 | 20 | from typing import Any, Callable, Optional, Protocol, TypeVar, Union, cast |
21 | 21 |
|
22 | 22 | import wrapt |
| 23 | +from typing_extensions import Self |
23 | 24 |
|
24 | 25 | from testcontainers.core.config import testcontainers_config |
25 | 26 | from testcontainers.core.utils import setup_logger |
@@ -77,23 +78,23 @@ def __init__(self) -> None: |
77 | 78 | self._poll_interval: float = testcontainers_config.sleep_time |
78 | 79 | self._transient_exceptions: list[type[Exception]] = [*TRANSIENT_EXCEPTIONS] |
79 | 80 |
|
80 | | - def with_startup_timeout(self, timeout: Union[int, timedelta]) -> "WaitStrategy": |
| 81 | + def with_startup_timeout(self, timeout: Union[int, timedelta]) -> Self: |
81 | 82 | """Set the maximum time to wait for the container to be ready.""" |
82 | 83 | if isinstance(timeout, timedelta): |
83 | 84 | self._startup_timeout = float(int(timeout.total_seconds())) |
84 | 85 | else: |
85 | 86 | self._startup_timeout = float(timeout) |
86 | 87 | return self |
87 | 88 |
|
88 | | - def with_poll_interval(self, interval: Union[float, timedelta]) -> "WaitStrategy": |
| 89 | + def with_poll_interval(self, interval: Union[float, timedelta]) -> Self: |
89 | 90 | """Set how frequently to check if the container is ready.""" |
90 | 91 | if isinstance(interval, timedelta): |
91 | 92 | self._poll_interval = interval.total_seconds() |
92 | 93 | else: |
93 | 94 | self._poll_interval = interval |
94 | 95 | return self |
95 | 96 |
|
96 | | - def with_transient_exceptions(self, *transient_exceptions: type[Exception]) -> "WaitStrategy": |
| 97 | + def with_transient_exceptions(self, *transient_exceptions: type[Exception]) -> Self: |
97 | 98 | self._transient_exceptions.extend(transient_exceptions) |
98 | 99 | return self |
99 | 100 |
|
|
0 commit comments