From f3396b320246f8446a4f5d6961d77138a4d91e94 Mon Sep 17 00:00:00 2001 From: Giovanni Barillari Date: Thu, 13 Jun 2024 15:22:02 +0200 Subject: [PATCH] Auto str conversion for constants --- granian/constants.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/granian/constants.py b/granian/constants.py index f6a452de..e2955d85 100644 --- a/granian/constants.py +++ b/granian/constants.py @@ -1,25 +1,30 @@ from enum import Enum -class Interfaces(str, Enum): +class StrEnum(str, Enum): + def __str__(self) -> str: + return str(self.value) + + +class Interfaces(StrEnum): ASGI = 'asgi' ASGINL = 'asginl' RSGI = 'rsgi' WSGI = 'wsgi' -class HTTPModes(str, Enum): +class HTTPModes(StrEnum): auto = 'auto' http1 = '1' http2 = '2' -class ThreadModes(str, Enum): +class ThreadModes(StrEnum): runtime = 'runtime' workers = 'workers' -class Loops(str, Enum): +class Loops(StrEnum): auto = 'auto' asyncio = 'asyncio' uvloop = 'uvloop'