Skip to content

Commit

Permalink
fix: handle converter classes
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv committed Oct 9, 2023
1 parent 2574d06 commit ed0bdeb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion disnake/ext/commands/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import itertools
import math
import sys
import types
from abc import ABC, abstractmethod
from dataclasses import dataclass
from enum import Enum, EnumMeta
Expand Down Expand Up @@ -755,7 +756,12 @@ def parse_annotation(self, annotation: Any, converter_mode: bool = False) -> boo
return True

def parse_converter_annotation(self, converter: Callable, fallback_annotation: Any) -> None:
_, parameters = isolate_self(get_signature_parameters(converter))
if isinstance(converter, (types.FunctionType, types.MethodType)):
converter_func = converter
else:
# if converter isn't a function/method, it should be a callable object/type
converter_func = converter.__call__
_, parameters = isolate_self(get_signature_parameters(converter_func))

if len(parameters) != 1:
raise TypeError(
Expand Down

0 comments on commit ed0bdeb

Please sign in to comment.