Considder an example like this which is explicitly written to support both numpy 2 and legacy numpy
import warnings
try:
from numpy.exceptions import VisibleDeprecationWarning
except ImportError:
# numpy < 1.25.0
from numpy import VisibleDeprecationWarning
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
category=VisibleDeprecationWarning,
message="Creating an ndarray from ragged nested sequences",
)
Running ruff check file.py with NPY201 enabled triggers
error: Failed to create fix for Numpy2Deprecation: Unable to insert `VisibleDeprecationWarning` into scope due to name conflict
src\qcodes\utils\numpy_utils.py:13:18: NPY201 `np.VisibleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.VisibleDeprecationWarning` instead.
|
11 | warnings.filterwarnings(
12 | "ignore",
13 | category=VisibleDeprecationWarning,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201
14 | message="Creating an ndarray from ragged nested sequences",
15 | )
|
= help: Replace with `numpy.exceptions.VisibleDeprecationWarning`
This 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:
[tool.ruff.lint]
select = ["NPY201"]
Considder an example like this which is explicitly written to support both numpy 2 and legacy numpy
Running
ruff check file.pywith 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: