-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
TYP: type hint numpy.polynomial
#26897
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
Conversation
0ce29c8
to
d0945bd
Compare
numpy.polynomial
numpy.polynomial
…` through generic type params
… due to (many) mypy bugs
c7998c2
to
ef3278a
Compare
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.
This looks great, thanks a lot @jorenham!
This PR is too large for me (or anyone else at this moment I think) to review line by line. I do want to get this in for 2.1.0 though, since it's a lot of work and there's a lot of user demand for improved type annotations. So I reviewed by spot checking some of the annotations themselves, and looking at the tests. I didn't find any obvious problems, and this is clearly a significant improvement, so I'll go ahead and merge it. I'm confident it's in good shape overall, and in case we get reports about issues later they can be addressed then.
For this reason, I have made the annotations slightly less precise than was possible, because it would harm the readability too much, by e.g. by requiring 30 overloads.
Good call - I think you struck the right balance here.
DOC: Add release notes for #26897
The underrated
numpy.polynomial
gem deserves to have proper type annotations; so here's my attempt 😄.Previously, there only were blank (and outdated) stubgen stubs.
This PR replaces them with hand-crafted and type-tested ones.
I did my best to avoid making the stubs too difficult to read / maintain.
For this reason, I have made the annotations slightly less precise than was possible, because it would harm the readability too much, by e.g. by requiring 30 overloads.
For the new internal type-aliases and protocols, I attempted to stay close to the numpy naming-scheme. For example
_SeriesLikeComplex_co
represents a 1-d array-like, limited to have anumber
,bool
, orobject
scalar type.