diff --git a/crates/ruff_linter/resources/test/fixtures/numpy/NPY201.py b/crates/ruff_linter/resources/test/fixtures/numpy/NPY201.py index ec7108d176..01846b92b6 100644 --- a/crates/ruff_linter/resources/test/fixtures/numpy/NPY201.py +++ b/crates/ruff_linter/resources/test/fixtures/numpy/NPY201.py @@ -68,3 +68,5 @@ def func(): np.longfloat(12+34j) np.lookfor + + np.NAN diff --git a/crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs b/crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs index 6b2f4a396f..9773fd208c 100644 --- a/crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs +++ b/crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs @@ -380,8 +380,8 @@ pub(crate) fn numpy_2_0_deprecation(checker: &mut Checker, expr: &Expr) { guideline: None, }, }), - ["numpy", "NaN"] => Some(Replacement { - existing: "NaN", + ["numpy", existing @ ("NaN" | "NAN")] => Some(Replacement { + existing, details: Details::AutoImport { path: "numpy", name: "nan", diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap index 118febb550..1799f3ef12 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap @@ -552,6 +552,7 @@ NPY201.py:68:5: NPY201 [*] `np.longfloat` will be removed in NumPy 2.0. Use `num 68 |+ np.longdouble(12+34j) 69 69 | 70 70 | np.lookfor +71 71 | NPY201.py:70:5: NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPy’s documentation directly. | @@ -559,4 +560,22 @@ NPY201.py:70:5: NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPy 69 | 70 | np.lookfor | ^^^^^^^^^^ NPY201 +71 | +72 | np.NAN | + +NPY201.py:72:5: NPY201 [*] `np.NAN` will be removed in NumPy 2.0. Use `numpy.nan` instead. + | +70 | np.lookfor +71 | +72 | np.NAN + | ^^^^^^ NPY201 + | + = help: Replace with `numpy.nan` + +ℹ Safe fix +69 69 | +70 70 | np.lookfor +71 71 | +72 |- np.NAN + 72 |+ np.nan