Browse Source

Fix Optional type hints not respecting explicitly set defaults

pull/7545/head
Rapptz 3 years ago
parent
commit
9fd63ad7f3
  1. 9
      discord/app_commands/transformers.py

9
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:

Loading…
Cancel
Save