Repository navigation
typing improvements - #2435
typing improvements#2435mjpieters wants to merge 5 commits into
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This was resolved in typeshed and newer mypy versions have inherited the fix.
0c8860b to
4012639
Compare
- start_response() must return a write(bytes) function, even though this is now deprecated. It's fine to be a no-op here. - sys.exc_info() can return (None, None, None), so make sure to handle that case.
Being explicit about the parameters helps find bugs and makes the library easier to use for users. - Tell mypy to disallow generics without parameter values - Give all generic types parameters values
Without these, type inference would be required, the output of which can differ between type checkers. Explict fields also serves as documentation and can be a place to add explicit field descriptions in future.
4012639 to
fa0486f
Compare
|
Thanks! Yup, I'm on board with us working towards stricter typing if that helps our users. I've outlined an incremental approach that I think would work well in #2436. |
|
I actually tried to break this PR up into different aspects; if you view each commit as a separate PR, would that work better? (If you are familiar with stacked diffs, then that's the approach I've been following here). If you rather have these as actual separate PRs I'm happy to rework these. |
I would prefer separate pull requests, yes. |
|
@mjpieters thank you for the super valuable contribution and the very clean commit history. I went ahead and split up your PR into one PR per commit (#2468 , #2467 , #2466 and #2469) so that it can be reviewed that way as well. I preserved your authorship of the commits. I also opened #2470 and #2472 to add those mypy flags. The only code changes were removing a couple of |
|
We've now merged all of these except #2496. I think we can close this issue. Thank you so much for for working on this @mjpieters! |
Excellent, I've been trying to find some time to do the same, so this is very helpful, thanks! |
This is a series of patches to improve the quality of the type hints provided
by httpx. These type hint updates were driven by our use of httpx in a project
with pyright configured in strict mode, which sets a high bar for type hint
completeness in 3rd party libraries such as httpx.
In the process, I found that the WSGITransport implementation had small issues
and fixed those in situ.
Without this patch, the output of
pyright --verifytypes httpxproduces:With these patches, the output will became:
Included commits: