From faaebc1e38d29df3a3bbcb56a0a5c2d4391b95ff Mon Sep 17 00:00:00 2001 From: FidelusAleksander Date: Fri, 29 May 2026 17:07:56 +0200 Subject: [PATCH] fix(cosmosdb): replace distutils.strtobool removed in Python 3.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit distutils was deprecated in Python 3.10 (PEP 632) and removed in 3.12. The cosmosdb module imports distutils.util.strtobool, which causes an ImportError on Python 3.12+. Replace with inline env-var truthiness checks against a module-level constant — no helper function or external dependency needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- modules/cosmosdb/testcontainers/cosmosdb/_emulator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/cosmosdb/testcontainers/cosmosdb/_emulator.py b/modules/cosmosdb/testcontainers/cosmosdb/_emulator.py index 161a01c29..6db14174b 100644 --- a/modules/cosmosdb/testcontainers/cosmosdb/_emulator.py +++ b/modules/cosmosdb/testcontainers/cosmosdb/_emulator.py @@ -2,7 +2,6 @@ import socket import ssl from collections.abc import Iterable -from distutils.util import strtobool from urllib.error import HTTPError, URLError from urllib.request import urlopen @@ -16,6 +15,7 @@ __all__ = ["CosmosDBEmulatorContainer"] EMULATOR_PORT = 8081 +_ENV_TRUTHY = {"true", "1", "yes"} class CosmosDBEmulatorContainer(DockerContainer): @@ -32,12 +32,12 @@ def __init__( "AZURE_COSMOS_EMULATOR_IMAGE", "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest" ), partition_count: int = os.getenv("AZURE_COSMOS_EMULATOR_PARTITION_COUNT", None), - enable_data_persistence: bool = strtobool(os.getenv("AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE", "false")), + enable_data_persistence: bool = os.getenv("AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE", "false").strip().lower() in _ENV_TRUTHY, key: str = os.getenv( "AZURE_COSMOS_EMULATOR_KEY", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", ), - bind_ports: bool = strtobool(os.getenv("AZURE_COSMOS_EMULATOR_BIND_PORTS", "true")), + bind_ports: bool = os.getenv("AZURE_COSMOS_EMULATOR_BIND_PORTS", "true").strip().lower() in _ENV_TRUTHY, endpoint_ports: Iterable[int] = [], **other_kwargs, ):