TYP: fix incorrect type annotations for optional parameters in stats#17226
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
|
@pllim I can't merge this because the change log check is stuck. How to fix? |
There was a problem hiding this comment.
There are a few others that need to be updated.
2b17c3e to
3526722
Compare
|
The project is not maintaining configuration for any type checkers and the small fraction of annotated code in |
Description
This is a direct follow up to #16562 were some confusion around optional parameters and the meaning of
| Noneas a type hint crept in. I initially explained the issue in a comment that I'll reproduce here for convenience:I grepped for the regular expression
(float|int) \| None = [\d\.]to discover incorrect cases (also a couple correct ones !). Inspecting the code for where these parameters were used quickly revealed that in 22 cases, passingNonewouldn't make sense and would immediately trigger an exception. In some cases, the docstrings also provided clear indications that the annotations were not correct: some parameters were documented asint, or None (optional)next to others documented asint (optional).Discovered while reviewing #17221
cc @jeffjennings