ST-API-stubs icon indicating copy to clipboard operation
ST-API-stubs copied to clipboard

How to deal with `Command.description()` with `want_event` is `True`?

Open jfcherng opened this issue 3 years ago • 1 comments

With want_event=True, we have something like

    def description(self, event: EventDict) -> str: ...

which violates the current stubs

    def description(self) -> str: ...

But if we use @overload like the following in our stubs

    @overload
    def description(self) -> str: ...
    @overload
    def description(self, event: EventDict) -> str: ...

then it will force users to use the following signature in their implementation

    def description(self, event: Optional[EventDict]=None) -> str:

which is annoying and breaks BC.


How do we fix this without using # type: ignore?

jfcherng avatar Mar 01 '22 05:03 jfcherng