From 9fd63ad7f3d95e38bb2a21f027bdccbf886371b0 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 12 Mar 2022 02:03:17 -0500 Subject: [PATCH] Fix Optional type hints not respecting explicitly set defaults --- discord/app_commands/transformers.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/discord/app_commands/transformers.py b/discord/app_commands/transformers.py index 7c50bfabc..6c7198505 100644 --- a/discord/app_commands/transformers.py +++ b/discord/app_commands/transformers.py @@ -627,10 +627,11 @@ def annotation_to_parameter(annotation: Any, parameter: inspect.Parameter) -> Co (inner, default) = get_supported_annotation(annotation) type = inner.type() - if default is MISSING: - default = parameter.default - if default is parameter.empty: - default = MISSING + + if default is MISSING or default is None: + param_default = parameter.default + if param_default is not parameter.empty: + default = param_default # Verify validity of the default parameter if default is not MISSING: