-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c848712
commit 0420ed1
Showing
3 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
crates/ruff_linter/resources/test/fixtures/numpy/NPY201_3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def func(): | ||
import numpy as np | ||
|
||
np.DTypePromotionError | ||
|
||
np.ModuleDeprecationWarning | ||
|
||
np.RankWarning | ||
|
||
np.TooHardError | ||
|
||
np.VisibleDeprecationWarning | ||
|
||
np.chararray | ||
|
||
np.format_parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
...les/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/numpy/mod.rs | ||
--- | ||
NPY201_3.py:4:5: NPY201 [*] `np.DTypePromotionError` will be removed in NumPy 2.0. Use `numpy.exceptions.DTypePromotionError` instead. | ||
| | ||
2 | import numpy as np | ||
3 | | ||
4 | np.DTypePromotionError | ||
| ^^^^^^^^^^^^^^^^^^^^^^ NPY201 | ||
5 | | ||
6 | np.ModuleDeprecationWarning | ||
| | ||
= help: Replace with `numpy.exceptions.DTypePromotionError` | ||
|
||
ℹ Safe fix | ||
1 |+from numpy.exceptions import DTypePromotionError | ||
1 2 | def func(): | ||
2 3 | import numpy as np | ||
3 4 | | ||
4 |- np.DTypePromotionError | ||
5 |+ DTypePromotionError | ||
5 6 | | ||
6 7 | np.ModuleDeprecationWarning | ||
7 8 | | ||
|
||
NPY201_3.py:6:5: NPY201 [*] `np.ModuleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.ModuleDeprecationWarning` instead. | ||
| | ||
4 | np.DTypePromotionError | ||
5 | | ||
6 | np.ModuleDeprecationWarning | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201 | ||
7 | | ||
8 | np.RankWarning | ||
| | ||
= help: Replace with `numpy.exceptions.ModuleDeprecationWarning` | ||
|
||
ℹ Safe fix | ||
1 |+from numpy.exceptions import ModuleDeprecationWarning | ||
1 2 | def func(): | ||
2 3 | import numpy as np | ||
3 4 | | ||
4 5 | np.DTypePromotionError | ||
5 6 | | ||
6 |- np.ModuleDeprecationWarning | ||
7 |+ ModuleDeprecationWarning | ||
7 8 | | ||
8 9 | np.RankWarning | ||
9 10 | | ||
|
||
NPY201_3.py:8:5: NPY201 [*] `np.RankWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.RankWarning` on NumPy 2.0, or ignore this warning on earlier versions. | ||
| | ||
6 | np.ModuleDeprecationWarning | ||
7 | | ||
8 | np.RankWarning | ||
| ^^^^^^^^^^^^^^ NPY201 | ||
9 | | ||
10 | np.TooHardError | ||
| | ||
= help: Replace with `numpy.exceptions.RankWarning` (requires NumPy 2.0 or greater) | ||
|
||
ℹ Unsafe fix | ||
1 |+from numpy.exceptions import RankWarning | ||
1 2 | def func(): | ||
2 3 | import numpy as np | ||
3 4 | | ||
-------------------------------------------------------------------------------- | ||
5 6 | | ||
6 7 | np.ModuleDeprecationWarning | ||
7 8 | | ||
8 |- np.RankWarning | ||
9 |+ RankWarning | ||
9 10 | | ||
10 11 | np.TooHardError | ||
11 12 | | ||
|
||
NPY201_3.py:10:5: NPY201 [*] `np.TooHardError` will be removed in NumPy 2.0. Use `numpy.exceptions.TooHardError` instead. | ||
| | ||
8 | np.RankWarning | ||
9 | | ||
10 | np.TooHardError | ||
| ^^^^^^^^^^^^^^^ NPY201 | ||
11 | | ||
12 | np.VisibleDeprecationWarning | ||
| | ||
= help: Replace with `numpy.exceptions.TooHardError` | ||
|
||
ℹ Safe fix | ||
1 |+from numpy.exceptions import TooHardError | ||
1 2 | def func(): | ||
2 3 | import numpy as np | ||
3 4 | | ||
-------------------------------------------------------------------------------- | ||
7 8 | | ||
8 9 | np.RankWarning | ||
9 10 | | ||
10 |- np.TooHardError | ||
11 |+ TooHardError | ||
11 12 | | ||
12 13 | np.VisibleDeprecationWarning | ||
13 14 | | ||
|
||
NPY201_3.py:12:5: NPY201 [*] `np.VisibleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.VisibleDeprecationWarning` instead. | ||
| | ||
10 | np.TooHardError | ||
11 | | ||
12 | np.VisibleDeprecationWarning | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201 | ||
13 | | ||
14 | np.chararray | ||
| | ||
= help: Replace with `numpy.exceptions.VisibleDeprecationWarning` | ||
|
||
ℹ Safe fix | ||
1 |+from numpy.exceptions import VisibleDeprecationWarning | ||
1 2 | def func(): | ||
2 3 | import numpy as np | ||
3 4 | | ||
-------------------------------------------------------------------------------- | ||
9 10 | | ||
10 11 | np.TooHardError | ||
11 12 | | ||
12 |- np.VisibleDeprecationWarning | ||
13 |+ VisibleDeprecationWarning | ||
13 14 | | ||
14 15 | np.chararray | ||
15 16 | | ||
|
||
NPY201_3.py:14:5: NPY201 [*] `np.chararray` will be removed in NumPy 2.0. Use `numpy.char.chararray` instead. | ||
| | ||
12 | np.VisibleDeprecationWarning | ||
13 | | ||
14 | np.chararray | ||
| ^^^^^^^^^^^^ NPY201 | ||
15 | | ||
16 | np.format_parser | ||
| | ||
= help: Replace with `numpy.char.chararray` | ||
|
||
ℹ Safe fix | ||
1 |+from numpy.char import chararray | ||
1 2 | def func(): | ||
2 3 | import numpy as np | ||
3 4 | | ||
-------------------------------------------------------------------------------- | ||
11 12 | | ||
12 13 | np.VisibleDeprecationWarning | ||
13 14 | | ||
14 |- np.chararray | ||
15 |+ chararray | ||
15 16 | | ||
16 17 | np.format_parser | ||
|
||
NPY201_3.py:16:5: NPY201 [*] `np.format_parser` will be removed in NumPy 2.0. Use `numpy.rec.format_parser` instead. | ||
| | ||
14 | np.chararray | ||
15 | | ||
16 | np.format_parser | ||
| ^^^^^^^^^^^^^^^^ NPY201 | ||
| | ||
= help: Replace with `numpy.rec.format_parser` | ||
|
||
ℹ Safe fix | ||
1 |+from numpy.rec import format_parser | ||
1 2 | def func(): | ||
2 3 | import numpy as np | ||
3 4 | | ||
-------------------------------------------------------------------------------- | ||
13 14 | | ||
14 15 | np.chararray | ||
15 16 | | ||
16 |- np.format_parser | ||
17 |+ format_parser |