-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
NPY201 triggers on code written to support both numpy 2 and legacy numpy #12476
Comments
I can see how the violation is undesired in this case, and we could probably specialize the rule to detect this very specific pattern. But I think it's also valid to use a suppression comment in this case to explicitly state that the use of the deprecated API is fine. @mtsokol what do you think? |
I think this pattern is likely to be quite common for projects that want to write code which is compatible with both versions of numpy. Maintaining compatibility with both versions is likely to be something that many projects are going to want to do for a while, as well. I'd be okay with not flagging deprecated numpy imports iff:
We should make sure all |
That makes sense to me. We should have code to detect the current set of handled exceptions. |
@MichaReiser I agree that this One note: Apart from But generally |
Thanks everybody for the input.
I personally would be fine with just adding a suppression comment as long as this limitation is documented for the rule. |
I'm working on a fix as per my suggestion in #12476 (comment). |
Considder an example like this which is explicitly written to support both numpy 2 and legacy numpy
Running
ruff check file.py
with NPY201 enabled triggersThis is a false positive since the deprecated location is only used in legacy numpy versions that do not have a exceptions submodule.
This started happening in 0.5.1 probably as a result of #12065
Keyworkds Numpy, NPY201
Ruff 0.5.1 to 0.5.4
Config:
The text was updated successfully, but these errors were encountered: