-
Notifications
You must be signed in to change notification settings - Fork 280
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
TYP: Fix typing in numpy2_compat.py #5101
TYP: Fix typing in numpy2_compat.py #5101
Conversation
This seems harmless at first sight but I don't have the faintest idea why this suddenly started to fail. Do you ? |
@neutrinoceros part of the reason for the ping was the hope that you'd have an idea offhand of why this was needed and I confess I didn't look into it too deeply :) But looking again now I think I figured it out! np 2.2.2 was released last week and gets picked up in the type checking test here and has a number of typing-related changes (Full release notes). This change numpy/numpy#28178 would fix the previous attr-defined failure (and give rise to unused error code failure reported in #5100 ). But just removing the ignore (which is what I first tried locally) results in a new error:
which... I didn't know what to do with, so added the import numpy as np
+from typing import Callable
+trapezoid: Callable
if hasattr(np, "trapezoid"):
# np.trapz is deprecated in numpy 2.0 in favor of np.trapezoid
trapezoid = np.trapezoid
else:
- trapezoid = np.trapz # type: ignore[assignment] # noqa: NPY201
+ trapezoid = np.trapz # noqa: NPY201 I'm just not sure if |
Ow, that makes sense ! I knew about numpy 2.2.2 but somehow missed the connection. Welp, now there's not even a residual doubt about it; we should only aim at typechecking against the latest version of numpy at this point. Thanks for the clarification ! |
@meeseeksdev backport to yt-4.4.x |
Close #5100