mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
[numpy
] deprecated type aliases (#2810)
Closes https://github.com/charliermarsh/ruff/issues/2455 Used `NPY` as prefix code as agreed in the issue.
This commit is contained in:
parent
c0eb5c28d1
commit
ac028cd9f8
15 changed files with 344 additions and 9 deletions
26
docs/rules/deprecated-type-alias.md
Normal file
26
docs/rules/deprecated-type-alias.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
# deprecated-type-alias (NPY001)
|
||||
|
||||
Autofix is always available.
|
||||
|
||||
## What it does
|
||||
Checks for deprecated NumPy type aliases.
|
||||
|
||||
## Why is this bad?
|
||||
NumPy's `np.int` has long been an alias of the builtin `int`. The same
|
||||
goes for `np.float`, `np.bool`, and others. These aliases exist
|
||||
primarily primarily for historic reasons, and have been a cause of
|
||||
frequent confusion for newcomers.
|
||||
|
||||
These aliases were been deprecated in 1.20, and removed in 1.24.
|
||||
|
||||
## Examples
|
||||
```python
|
||||
import numpy as np
|
||||
|
||||
np.bool
|
||||
```
|
||||
|
||||
Use instead:
|
||||
```python
|
||||
bool
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue