Skip to content

Commit c01d19c

Browse files
committed
fix: Fix issue where subclassed converters weren't accepted
1 parent f5d1760 commit c01d19c

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

pyslash/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
from .converters import convert
99
from .decorators import slash, slash_cog
1010

11-
__version__ = "1.1.0"
11+
__version__ = "1.1.1rc1"

pyslash/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def get_slash_command_type(annotation: Any) -> SlashCommandOptionType:
106106
No parameter type could be found
107107
"""
108108
# If it's a converter or an optional of a converter, it will always be a string
109-
if get_root_type(annotation) == commands.Converter:
109+
if issubclass(get_root_type(annotation), commands.Converter):
110110
return SlashCommandOptionType.STRING
111111

112112
type_ = SlashCommandOptionType.from_type(get_root_type(annotation))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
install_requires = f.readlines()
99

1010
setup(name='dpyslash',
11-
version='1.1.0',
11+
version='1.1.1rc1',
1212
description='Improves slash commands for Python',
1313
author='starsflower',
1414
url='https://github.com/starsflower/discordpy-slash-commands',

tests/test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ def func(foo: str, bar: Union[Literal[1], Literal[2, "name"]], baz: Union[comman
6868
"required": False,
6969
"choices": []
7070
})
71+
72+
def test_optional_converter(self):
73+
def func(baz: Optional[commands.Converter] = "bin"):
74+
pass
75+
76+
kwargs, _ = get_slash_kwargs("test", "test", [], False, func)
77+
self.assertEqual(kwargs["options"][0], {
78+
"name": "baz",
79+
"description": "No description",
80+
"type": SlashCommandOptionType.STRING,
81+
"required": False,
82+
"choices": []
83+
})
7184

7285

7386
if __name__ == "__main__":

0 commit comments

Comments
 (0)