feat: add proper typing support for bridge contexts#3251
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/3251/head:pr-3251
git checkout pr-3251This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3251/head |
Paillat-dev
left a comment
There was a problem hiding this comment.
lgtm although we should probably shift focus away from bridge and the exts for the time being until we conclude what to do with them
| def typing(self, *args, **kwargs) -> Typing | DeferTyping: | ||
| """ | ||
| Returns a context manager that allows you to type for an indefinite period of time. | ||
| In :class:`BridgeExtContext`, this will be :meth:`~Context.typing` while in :class:`BridgeApplicationContext`, | ||
| this is equivalent to a defer() call and does not do any typing calls. | ||
| """ | ||
| return self._typing(*args, **kwargs) |
There was a problem hiding this comment.
Why do we need both typing and _typing ?
There was a problem hiding this comment.
This is the template method pattern already used by respond, defer and others throughout the file.
|
(Actionable) reviews have been addressed! As for shifting focus, that's understandable. This was just meant to be a quick PR for a simple thing at the end of the day. |
Summary
This PR adds a new function to
BridgeContextand its two subclasses:typing(). InBridgeExtContext, this functions just likeContext.typing, but inBridgeApplicationContext, this does a defer. This is most useful when you have a long running bridge command that lasts longer than whattrigger_typing()allows.An example (which showcases this better than any description could do) is below:
This is a breaking change.
ApplicationContexthas atyping()function that types in the channel the command is being run, although the usefulness of this is debatable for slash commands; regardless, this overwrites that function.Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.