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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more type annotations #4657
Conversation
Import Optional and avoid using DeltaGenerator directly in cast.
I'd love to add more annotations, but I'd like to know if this is something you guys find valuable first. |
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.
Thanks for the contribution @harahu!
We certainly find this valuable and would appreciate additional PRs adding more annotations 馃檪
I have a few small comments / one question, but for the most part this looks close to being ready to merge to me
Good to know! Will split my work over multiple PRs then, in order to maintain ease of review and merging. This is implying that I won't be adding more annotations to this PR, so feel free to merge it as you feel like. |
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.
Thanks again @harahu!
@harahu I've gone ahead and approved + merged about 5 of the newly opened PRs. Another one is more or less good to go as well, but I had one small suggestion on it. There's a bit of a wrinkle in getting the rest of the PRs merged that we'll need to figure out how to resolve. I'm not sure how this slipped by CI as I would have expected e2e tests to fail due to this (my best guess right now is that we somehow end up caching The issue is that we conditionally install the (CC @AnOctopus @tconkling as they're likely to have opinions on how to best resolve this) |
I'm sorry! Wasn't aware that it was a conditional install.
@vdonato There shouldn't be much risk, I think. It's also worth noting that the There's a remaining question about how to avoid types needlessly being imported from |
Update: I've now added branching imports to the remaining PRs. That means some of them are ready to merge, while others, using the |
I've been confused by this conditional installation - and my feeling is that yeah, let's just always install typing_extensions no matter what! We could just do that in a separate PR now, if it makes things easier? |
(Also, @harahu - thanks so much for this work! Big fan of explicit typing.) |
If you do that, then all my PRs will be ready to merge, so am all for it 馃槈 |
The pleasure is mine! I love Streamlit, but it's going to be nice to get rid of my custom typed wrappers of your API... |
@tconkling I made and additional PR #4697, making typing-extensions an unconditional dependency. I hope this is helpful. |
馃摎 Context
Add some low hanging type annotations to the code base.
I run
mypy
with fairly strict settings, including https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-disallow-untyped-callsThis results in a lot of errors for various parts of the Streamlit API. This PR adds type annotations to a few APIs I use heavily, in order to silence those errors.
馃 Description of Changes
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.