From a553d5d95adb9339ca1ba62fcb375ab34e02d013 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Thu, 31 Mar 2022 20:45:59 -0700 Subject: [PATCH] fix: replace distutils.util.strtobool with our own Reference from github.com/PostHog/posthog/pull/4631/commits/341c28da0f6d33d6fb12fe443766a2d822ff0097 This fixes a deprecation warning regarding distutil's strtobool. Signed-off-by: Kevin Morris --- aurweb/util.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/aurweb/util.py b/aurweb/util.py index 6759794f..5138f7da 100644 --- a/aurweb/util.py +++ b/aurweb/util.py @@ -4,7 +4,6 @@ import secrets import string from datetime import datetime -from distutils.util import strtobool as _strtobool from http import HTTPStatus from subprocess import PIPE, Popen from typing import Callable, Iterable, List, Tuple, Union @@ -114,9 +113,9 @@ def sanitize_params(offset: str, per_page: str) -> Tuple[int, int]: def strtobool(value: Union[str, bool]) -> bool: - if isinstance(value, str): - return _strtobool(value or "False") - return value + if not value: + return False + return str(value).lower() in ("y", "yes", "t", "true", "on", "1") def file_hash(filepath: str, hash_function: Callable) -> str: