From 6b75a8c8f935a23e848380e23e326ec9732ba2f0 Mon Sep 17 00:00:00 2001 From: Ben Berry-Allwood Date: Fri, 6 Sep 2024 16:56:59 +0100 Subject: [PATCH] fix: make functions in LetterCase members of the enum --- dataclasses_json/cfg.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dataclasses_json/cfg.py b/dataclasses_json/cfg.py index 930e51e0..3415cc4e 100644 --- a/dataclasses_json/cfg.py +++ b/dataclasses_json/cfg.py @@ -48,10 +48,13 @@ def __init__(self): class LetterCase(Enum): - CAMEL = camelcase - KEBAB = spinalcase - SNAKE = snakecase - PASCAL = pascalcase + CAMEL = functools.partial(camelcase) + KEBAB = functools.partial(spinalcase) + SNAKE = functools.partial(snakecase) + PASCAL = functools.partial(pascalcase) + + def __call__(self, string: str) -> str: + return self.value(string) def config(metadata: Optional[dict] = None, *,