[numpy] Update NPY201: add np.NAN to exception (#12292)

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
Matthias 2024-07-12 14:09:55 +02:00 committed by GitHub
parent b6545ce5d6
commit 17e84d5f40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 2 deletions

View file

@ -68,3 +68,5 @@ def func():
np.longfloat(12+34j) np.longfloat(12+34j)
np.lookfor np.lookfor
np.NAN

View file

@ -380,8 +380,8 @@ pub(crate) fn numpy_2_0_deprecation(checker: &mut Checker, expr: &Expr) {
guideline: None, guideline: None,
}, },
}), }),
["numpy", "NaN"] => Some(Replacement { ["numpy", existing @ ("NaN" | "NAN")] => Some(Replacement {
existing: "NaN", existing,
details: Details::AutoImport { details: Details::AutoImport {
path: "numpy", path: "numpy",
name: "nan", name: "nan",

View file

@ -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) 68 |+ np.longdouble(12+34j)
69 69 | 69 69 |
70 70 | np.lookfor 70 70 | np.lookfor
71 71 |
NPY201.py:70:5: NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPys documentation directly. NPY201.py:70:5: NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPys documentation directly.
| |
@ -559,4 +560,22 @@ NPY201.py:70:5: NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPy
69 | 69 |
70 | np.lookfor 70 | np.lookfor
| ^^^^^^^^^^ NPY201 | ^^^^^^^^^^ 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