From 5fff5252a5a4f181a0216788dc8d053c047c34a5 Mon Sep 17 00:00:00 2001 From: Chris Tomkins <80041880+cdtomkins@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:28:34 +0000 Subject: [PATCH] Remove need for distutils.util (distutils now deprecated) (#99) * Use setuptools to provide distutils.util (distutils deprecated w/ python >=3.12) * Improved implementation - no need for setuptools either --- tasks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tasks.py b/tasks.py index 8d4d2ca0d..3e3c043b8 100644 --- a/tasks.py +++ b/tasks.py @@ -1,6 +1,5 @@ """Development Tasks.""" -from distutils.util import strtobool from time import sleep import os import toml @@ -19,7 +18,14 @@ def is_truthy(arg): """ if isinstance(arg, bool): return arg - return bool(strtobool(arg)) + + val = str(arg).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 truthy value: `{arg}`") # Use pyinvoke configuration for default values, see http://docs.pyinvoke.org/en/stable/concepts/configuration.html