-
Notifications
You must be signed in to change notification settings - Fork 815
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
[Typing] Add type hint to sender
in widget messages?
#1813
Comments
Great in principle. But I suspect that will break typing somewhere. Feels like a LSP violation. |
Perhaps the way to go here would be to make |
Assuming LSP means Liskov's Substitution Principle, I can't see how that could be true. |
Reading this on the mypy docs makes me wonder whether I'm getting things the other way around. |
Work on #1831 seems to suggest there is no issue with LSP. |
Ok, feel free to add that. |
This became irrelevant as of #1940. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
The class
Message
defines the attributesender
as being of the typeMessageTarget
, which is a fairly generic protocol. Fine.When writing custom messages, wouldn't it make sense to add an explicit type hint to mark the class variable
sender
as being of the type of the widget within which the message is being defined?E.g., won't this make sense:
By adding
sender: MyWidget
in the body of the class, IDEs and static checkers will let me make use of.sender
as of being the type I already know it is.The text was updated successfully, but these errors were encountered: