-
-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: make ApplicationContext.user
non-optional
#1647
refactor: make ApplicationContext.user
non-optional
#1647
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively I feel it would be better to keep Interaction.user
optional (since it is), and instead make ApplicationContext.user
non-optional with a type: ignore
.
Why keep |
Because we should not make invalid type hints, which is what this would currently do. We can set it as optional and |
It'll only be wrong internally when PONG-ing interactions, if done |
ping pong |
I do not agree with this approach. It's a way better idea to just change the type hints. It'll be better in the long run. |
Why? In the solution I proposed,
That sounds like a potentially better approach. If we go this route, the best course of action may be closing this PR in favor of a new PR for the split-interaction approach. |
Splitting interaction classes is a major change and will most likely be breaking. It might just as well create more type issues like the ones this pr aims to solve. |
interaction.user
non-optionalApplicationContext.user
non-optional
Co-authored-by: BobDotCom <[email protected]>
ApplicationContext.user
non-optionalApplicationContext.user
non-optional
I've made changes after we decided to only make |
Summary
At least one of the
member
anduser
fields in the interaction payload will be present unless it's a PING interaction. This change prevents type issues from occuring almost everywhereInteraction.user
orApplicationContext.user
is used without a type check.This will be a breaking change in case this attribute is accessed in a PING handler (such a case isn't in the lib) even though it would always be
None
.Information
Checklist
type: ignore
comments were used, a comment is also left explaining why.