Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Support for Optional[...] in CommandArg #302

Closed
Sigmanificient opened this issue Dec 12, 2021 · 1 comment
Closed

Support for Optional[...] in CommandArg #302

Sigmanificient opened this issue Dec 12, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@Sigmanificient
Copy link
Member

Sigmanificient commented Dec 12, 2021

trying to use
CommandArg[Optional[str], Description["..."]] = None
raises

Traceback (most recent call last):
  File "/home/sigmanificient/PycharmProjects/Pincers/Pincer/dev/context.py", line 8, in <module>
    class Bot(Client):
  File "/home/sigmanificient/PycharmProjects/Pincers/Pincer/dev/context.py", line 10, in Bot
    async def a_command(
  File "/home/sigmanificient/PycharmProjects/Pincers/Pincer/pincer/commands/commands.py", line 237, in command
    command_type = _options_type_link[annotation.command_type]
KeyError: typing.Union[str, **NoneType]

the "working" way to do it is the following:

    async def a_command(
        self,
        ctx: MessageContext,
        content: CommandArg[str, Description["..."]] = None,
    ) -> Embed:

But this doesnt seems really fine as None doesn't seems to be typed.
The first argument should be Optional[str]

@Sigmanificient Sigmanificient added the bug Something isn't working label Dec 12, 2021
@ooliver1
Copy link
Contributor

ooliver1 commented Aug 9, 2022

#480 the fixes part (of course) did not link and close this issue properly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants