未验证 提交 66e0720d 编写于 作者: N Nyakku Shigure 提交者: GitHub

[CodeStyle][NPY001] replace numpy deprecated type alias (#51524)

* [CodeStyle] initial ruff config

* update F401 config

* [CodeStyle][NPY001] replace numpy deprecated type alias
上级 17eb43bc
......@@ -78,6 +78,11 @@ repos:
- --ignore-pass-after-docstring
- --ignore-init-module-imports
- --exclude=python/paddle/fluid/[!t]**,python/paddle/fluid/tra**
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
- repo: local
hooks:
- id: pylint-doc-string
......
......@@ -17,3 +17,45 @@ extend_skip_glob = [
"python/paddle/fluid/tests/unittests/npu/**",
"python/paddle/fluid/tests/unittests/mlu/**",
]
[tool.ruff]
exclude = [
"./build",
"./python/paddle/fluid/[!t]**",
"./python/paddle/fluid/tra**",
"./python/paddle/utils/gast/**",
"./python/paddle/fluid/tests/unittests/npu/**",
"./python/paddle/fluid/tests/unittests/mlu/**",
]
target-version = "py37"
select = [
# Pyupgrade
"UP001",
"UP003",
"UP007",
"UP011",
"UP013",
"UP014",
"UP017",
"UP019",
"UP020",
"UP021",
"UP022",
"UP023",
"UP025",
"UP026",
"UP029",
"UP033",
"UP035",
"UP036",
# NumPy-specific rules
"NPY001",
]
unfixable = [
"NPY001"
]
[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
"setup.py" = ["UP036"]
......@@ -953,7 +953,7 @@ class TrtConvertElementwiseTestTwoInputSkipCase(TrtLayerAutoScanTest):
)
# Paddle mul support bool and TensorRT not
if op_type == "elementwise_mul":
return np.random.random(shape).astype(np.bool)
return np.random.random(shape).astype(np.bool_)
for shape in [[4], [4, 32], [2, 32, 16], [1, 8, 16, 32]]:
for op_type in [
......
......@@ -2185,7 +2185,7 @@ class OpTest(unittest.TestCase):
else:
abs_a = 1 if abs_a < 1e-3 else abs_a
if self.dtype == np.bool:
if self.dtype == np.bool_:
diff_mat = np.abs(a ^ b) / abs_a
else:
diff_mat = np.abs(a - b) / abs_a
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册