Open
Conversation
jbrinkman
reviewed
Dec 11, 2025
| """ | ||
| return int(super().get_exposed_port(self.port)) | ||
|
|
||
| @wait_container_is_ready(ValkeyNotReady) |
There was a problem hiding this comment.
Deprecated Decorator Usage
Location: modules/valkey/testcontainers/valkey/__init__.py, line 113
Current Code:
@wait_container_is_ready(ValkeyNotReady)
def _connect(self) -> None:
"""Wait for Valkey to be ready by sending PING command."""
# ... connection logicIssue:
The @wait_container_is_ready decorator is deprecated in the codebase. Recent commits show active migration away from this pattern:
- PR feat: Add ExecWaitStrategy and migrate Postgres from deprecated decorator testcontainers/testcontainers-python#935: Postgres migrated to
ExecWaitStrategy - PR fix(minio): Use wait strategy instead of deprecated decorator testcontainers/testcontainers-python#899: Minio migrated to wait strategies
- PR fix(elasticsearch): Use wait strategy instead of deprecated decorator testcontainers/testcontainers-python#915: Elasticsearch migrated to wait strategies
Evidence from Codebase:
# From pytest.ini_options filterwarnings:
"ignore:The @wait_container_is_ready decorator is deprecated.*:DeprecationWarning"Recommended Fix:
Migrate to modern wait strategy pattern:
from testcontainers.core.wait_strategies import ExecWaitStrategy
class ValkeyContainer(DockerContainer):
def __init__(self, image: str = "valkey/valkey:latest", port: int = 6379, **kwargs) -> None:
super().__init__(image, **kwargs)
self.port = port
self.password: Optional[str] = None
self.with_exposed_ports(self.port)
def start(self) -> "ValkeyContainer":
# Build wait strategy based on password
if self.password:
# Use custom wait strategy for authenticated connections
self.waiting_for(self._create_auth_wait_strategy())
else:
# Use exec strategy for simple PING
self.waiting_for(
ExecWaitStrategy(["valkey-cli", "ping"])
)
super().start()
return selfBenefits:
- Aligns with project direction
- More composable and testable
- Consistent with other modules
- Better error messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.