fix: replace distutils.strtobool() with locally implemented version per PEP 632
This commit is contained in:
parent
ac388d644b
commit
6f18c82879
|
@ -1,12 +1,25 @@
|
|||
import asyncio
|
||||
|
||||
from distutils.util import strtobool
|
||||
from os import getenv
|
||||
|
||||
from sanic.compat import OS_IS_WINDOWS
|
||||
from sanic.log import error_logger
|
||||
|
||||
|
||||
def strtobool(query: str) -> bool:
|
||||
"""
|
||||
reimplement strtobool per PEP 632 and python 3.12 deprecation
|
||||
|
||||
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.
|
||||
"""
|
||||
if query.lower() in ["y", "yes", "t", "true", "on", "1"]:
|
||||
return True
|
||||
elif query.lower() in ["n", "no", "f", "false", "off", "0"]:
|
||||
return False
|
||||
else:
|
||||
raise ValueError
|
||||
|
||||
|
||||
def try_use_uvloop() -> None:
|
||||
"""
|
||||
Use uvloop instead of the default asyncio loop.
|
||||
|
|
Loading…
Reference in New Issue
Block a user