Skip to content

Commit

Permalink
Use Self for all builder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
santi committed Apr 2, 2024
1 parent 16a47d6 commit c44887b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions core/testcontainers/core/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,29 @@ def __init__(
self._name = None
self._kwargs = kwargs

def with_env(self, key: str, value: str) -> "DockerContainer":
def with_env(self, key: str, value: str) -> Self:
self.env[key] = value
return self

def with_bind_ports(self, container: int, host: Optional[int] = None) -> "DockerContainer":
def with_bind_ports(self, container: int, host: Optional[int] = None) -> Self:
self.ports[container] = host
return self

def with_exposed_ports(self, *ports: int) -> "DockerContainer":
def with_exposed_ports(self, *ports: int) -> Self:
for port in ports:
self.ports[port] = None
return self

def with_kwargs(self, **kwargs) -> "DockerContainer":
def with_kwargs(self, **kwargs) -> Self:
self._kwargs = kwargs
return self

def maybe_emulate_amd64(self) -> "DockerContainer":
def maybe_emulate_amd64(self) -> Self:
if is_arm():
return self.with_kwargs(platform="linux/amd64")
return self

def start(self):
def start(self) -> Self:
if not RYUK_DISABLED and self.image != RYUK_IMAGE:
logger.debug("Creating Ryuk container")
Reaper.get_instance()
Expand Down Expand Up @@ -140,15 +140,15 @@ def get_exposed_port(self, port: int) -> str:
return port
return mapped_port

def with_command(self, command: str) -> "DockerContainer":
def with_command(self, command: str) -> Self:
self._command = command
return self

def with_name(self, name: str) -> "DockerContainer":
def with_name(self, name: str) -> Self:
self._name = name
return self

def with_volume_mapping(self, host: str, container: str, mode: str = "ro") -> "DockerContainer":
def with_volume_mapping(self, host: str, container: str, mode: str = "ro") -> Self:
mapping = {"bind": container, "mode": mode}
self.volumes[host] = mapping
return self
Expand Down

0 comments on commit c44887b

Please sign in to comment.