TYP: type hint numpy.polynomial#26897
Conversation
0ce29c8 to
d0945bd
Compare
numpy.polynomialnumpy.polynomial
…` through generic type params
… due to (many) mypy bugs
c7998c2 to
ef3278a
Compare
There was a problem hiding this comment.
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.polynomialgem 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_corepresents a 1-d array-like, limited to have anumber,bool, orobjectscalar type.