Skip to content
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

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

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/numpy/NPY201.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ def func():
np.longfloat(12+34j)

np.lookfor

np.NAN
Copy link
Contributor Author

@xmatthias xmatthias Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could also be moved next to np.NaN - which i'd find more appealing as it'd really belong there - but i found the diff on the .snap file to be rather large - as it changes all subsequent line numbers...

let me know if you'd prefer that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think either is fine.

Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,30 @@ 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.
|
68 | np.longfloat(12+34j)
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
Loading