mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-16 08:30:30 +00:00

Hi! This PR addresses https://github.com/astral-sh/ruff/issues/11093. It skips `np.bool` and `np.long` replacements as both of these names were reintroduced in NumPy 2.0 with a different meaning (https://github.com/numpy/numpy/pull/24922, https://github.com/numpy/numpy/pull/25080). With this change `NPY001` will no longer conflict with `NPY201`. For projects using NumPy 1.x `np.bool` and `np.long` has been deprecated and removed long time ago, and accessing them yields an informative error message.
25 lines
430 B
Python
25 lines
430 B
Python
import numpy as npy
|
|
import numpy as np
|
|
import numpy
|
|
|
|
# Error
|
|
npy.float
|
|
npy.int
|
|
|
|
if dtype == np.object:
|
|
...
|
|
|
|
result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex])
|
|
|
|
pdf = pd.DataFrame(
|
|
data=[[1, 2, 3]],
|
|
columns=["a", "b", "c"],
|
|
dtype=numpy.object,
|
|
)
|
|
|
|
_ = arr.astype(np.int)
|
|
|
|
# Regression test for: https://github.com/astral-sh/ruff/issues/6952
|
|
from numpy import float
|
|
|
|
float(1)
|