-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
types: missing type information for several common functions #19649
Comments
What mypy version are you using? |
0.910 |
Here's an example: https://github.com/scikit-hep/boost-histogram/blob/53ed9ee91fdc850eb309a908e96eafc4f03442fa/.pre-commit-config.yaml#L72-L78 (UHI, Hist, and boost-histogram were all affected). The interesting thing here is that in looking in NumPy's For example, removing this one
I see a possible problem, though. In following down So it's much less of a regression, and just a consequence of more but missing types. |
Per the error message: mypy is not complaining about an undefined function, it's complaining about a function whose arguments are unannotated. The relevant mypy flag, |
Yes, I thought this was a regression, but it appears it's actually slightly better that before but still partially typed. What is the process for adding types? Is someone adding them in batches, or is it something what would help out if I were to open a PR for the functions I'm interested in? And are the types always in |
If you want an up date overview of the current typing progress I'd recommend to keep an eye on #16546 and this is also a good starting point for if anyone is interested in contributing. The hope is to wrap up introducing some (basic?) annotations for the entire library for the 1.22 release, which I think is very much feasible at the current pace.
Yes, the type hints are currently exclusivvelly located in |
As of #20063 all functions mentioned in this issue are have been fully annotated. |
While there have been improvements to the static types, including a few functions being added, (at least) the following functions now are completely missing types:
np.frombuffer
np.histogram2d
np.histogramdd
np.broadcast_arrays
np.meshgrid
np.array_split
Also these, but I think there's a reason for these:
np.min
(should usenp.amin
)np.max
(should usenp.amax
)np.diag
(Matlab comp function fornp.diagonal
)Reproducing code example:
Use any of these function in mypy and upgrade from 1.20 to 1.21.
Error message:
A bunch of "Call to untyped function "frombuffer" in typed context" in every package I'm upgrading to use NumPy 1.21 in static typing.
NumPy/Python version information:
1.21.1, on Python 3.9.
The text was updated successfully, but these errors were encountered: