From 740c156cd81ebea6a8ed3f2457f73d3c5cbb4989 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Fri, 11 Mar 2022 08:06:11 -0500 Subject: [PATCH] Allow Optional transformers to work at runtime --- discord/app_commands/transformers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/discord/app_commands/transformers.py b/discord/app_commands/transformers.py index 330932e5c..7c50bfabc 100644 --- a/discord/app_commands/transformers.py +++ b/discord/app_commands/transformers.py @@ -241,6 +241,11 @@ class _TransformMetadata: def __init__(self, metadata: Type[Transformer]): self.metadata: Type[Transformer] = metadata + # This is needed to pass typing's type checks. + # e.g. Optional[Transform[discord.Member, MyTransformer]] + def __call__(self) -> None: + pass + async def _identity_transform(cls, interaction: Interaction, value: Any) -> Any: return value