A NumPy alias of a builtin type that NumPy 1.24 removed is used
What it finds
np.int, np.float, np.object: NumPy's aliases of the builtin types were deprecated in 1.20 and removed in 1.24, so the attribute raises AttributeError with current NumPy. The builtins themselves, or sized types such as np.int64, are meant. np.bool and np.long, which NumPy 2 brought back as names of its own types, are left alone.
From the rule's source, removed_numpy_alias.rs.
import numpyimport numpy as np def convert(values): a = np.array(values, dtype=np.int)tx0 reports: NumPy 1.24 removed numpy.int; use the builtin int b = values.astype(np.float)tx0 reports: NumPy 1.24 removed numpy.float; use the builtin float c = np.int64(1) d = np.float32(2) e = numpy.int(3)tx0 reports: NumPy 1.24 removed numpy.int f = np.bool_(True) g = other.int return a, b, c, d, e, f, g Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/python:removed-numpy-alias" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:removed-numpy-alias] reason="..."tx0 explain tx0/python:removed-numpy-alias shows the same in the terminal. Found a false positive? Report it.