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 <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-03-31 20:45:59 -07:00
parent cf4295a13e
commit a553d5d95a
No known key found for this signature in database
GPG key ID: F7E46DED420788F3

View file

@ -4,7 +4,6 @@ import secrets
import string import string
from datetime import datetime from datetime import datetime
from distutils.util import strtobool as _strtobool
from http import HTTPStatus from http import HTTPStatus
from subprocess import PIPE, Popen from subprocess import PIPE, Popen
from typing import Callable, Iterable, List, Tuple, Union 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: def strtobool(value: Union[str, bool]) -> bool:
if isinstance(value, str): if not value:
return _strtobool(value or "False") return False
return value return str(value).lower() in ("y", "yes", "t", "true", "on", "1")
def file_hash(filepath: str, hash_function: Callable) -> str: def file_hash(filepath: str, hash_function: Callable) -> str: