From 40e2d41f3b5c641a08b38dca01f155a137314c91 Mon Sep 17 00:00:00 2001 From: Dandiggas Date: Mon, 29 Apr 2024 21:21:20 +0100 Subject: [PATCH 1/2] added types to exec & tc_properties_get_tc_host --- core/testcontainers/core/config.py | 2 +- core/testcontainers/core/container.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/testcontainers/core/config.py b/core/testcontainers/core/config.py index 391c88bf..e84ca10e 100644 --- a/core/testcontainers/core/config.py +++ b/core/testcontainers/core/config.py @@ -47,7 +47,7 @@ class TestcontainersConfiguration: ryuk_reconnection_timeout: str = RYUK_RECONNECTION_TIMEOUT tc_properties: dict[str, str] = field(default_factory=read_tc_properties) - def tc_properties_get_tc_host(self): + def tc_properties_get_tc_host(self) -> str | None: return self.tc_properties.get("tc.host") @property diff --git a/core/testcontainers/core/container.py b/core/testcontainers/core/container.py index 4fa651e4..085fc58e 100644 --- a/core/testcontainers/core/container.py +++ b/core/testcontainers/core/container.py @@ -172,7 +172,7 @@ def get_logs(self) -> tuple[bytes, bytes]: raise ContainerStartException("Container should be started before getting logs") return self._container.logs(stderr=False), self._container.logs(stdout=False) - def exec(self, command) -> tuple[int, str]: + def exec(self, command) -> tuple[int, bytes]: if not self._container: raise ContainerStartException("Container should be started before executing a command") return self._container.exec_run(command) From a43d3b5e431b4fa0a72162d119ed2502b58806c7 Mon Sep 17 00:00:00 2001 From: Dandiggas Date: Thu, 16 May 2024 23:31:54 +0100 Subject: [PATCH 2/2] use union vs pipe (support python 3.9) --- core/testcontainers/core/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/testcontainers/core/config.py b/core/testcontainers/core/config.py index e84ca10e..1b3719e7 100644 --- a/core/testcontainers/core/config.py +++ b/core/testcontainers/core/config.py @@ -2,6 +2,7 @@ from os import environ from os.path import exists from pathlib import Path +from typing import Union MAX_TRIES = int(environ.get("TC_MAX_TRIES", 120)) SLEEP_TIME = int(environ.get("TC_POOLING_INTERVAL", 1)) @@ -47,7 +48,7 @@ class TestcontainersConfiguration: ryuk_reconnection_timeout: str = RYUK_RECONNECTION_TIMEOUT tc_properties: dict[str, str] = field(default_factory=read_tc_properties) - def tc_properties_get_tc_host(self) -> str | None: + def tc_properties_get_tc_host(self) -> Union[str, None]: return self.tc_properties.get("tc.host") @property