From 3f6786d737db91821ffa022550e076fb45461dc8 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 20:06:17 +0000 Subject: [PATCH] refactor: replace distutils.util.strtobool with custom implementation - Remove dependency on distutils which is deprecated in Python 3.10 and removed in 3.12 - Add custom strtobool implementation with identical functionality Co-Authored-By: natik@airbyte.io --- airbyte_cdk/sources/utils/transform.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/airbyte_cdk/sources/utils/transform.py b/airbyte_cdk/sources/utils/transform.py index 05c299560..9b14ea7b2 100644 --- a/airbyte_cdk/sources/utils/transform.py +++ b/airbyte_cdk/sources/utils/transform.py @@ -3,8 +3,22 @@ # import logging -from distutils.util import strtobool from enum import Flag, auto + + +def strtobool(val: str) -> bool: + """Convert a string representation of truth to True or False. + True values are 'y', 'yes', 't', 'true', 'on', and '1'; + False values are 'n', 'no', 'f', 'false', 'off', and '0'. + Raises ValueError if 'val' is anything else. + """ + val = val.lower() + if val in ('y', 'yes', 't', 'true', 'on', '1'): + return True + elif val in ('n', 'no', 'f', 'false', 'off', '0'): + return False + else: + raise ValueError(f"Invalid truth value {val}") from typing import Any, Callable, Dict, Generator, Mapping, Optional, cast from jsonschema import Draft7Validator, RefResolver, ValidationError, Validator, validators