diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6be33c740497..50b1175ffebc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/PyCQA/bandit - rev: '1.9.2' + rev: '1.9.3' hooks: - id: bandit pass_filenames: false @@ -64,7 +64,7 @@ repos: additional_dependencies: - tomli - repo: https://github.com/psf/black - rev: 25.12.0 + rev: 26.1.0 hooks: - id: black exclude: "dpnp/_version.py" diff --git a/dpnp/__init__.py b/dpnp/__init__.py index 5ec230977f98..02420107972f 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -566,7 +566,6 @@ kaiser, ) - # ============================================================================= # Helper functions # ============================================================================= diff --git a/dpnp/dpnp_container.py b/dpnp/dpnp_container.py index f019989a2ca8..4975db17c717 100644 --- a/dpnp/dpnp_container.py +++ b/dpnp/dpnp_container.py @@ -35,7 +35,6 @@ """ - import dpctl.tensor as dpt import dpctl.utils as dpu diff --git a/dpnp/dpnp_iface.py b/dpnp/dpnp_iface.py index 4cdc74c75ca0..fba1a215756a 100644 --- a/dpnp/dpnp_iface.py +++ b/dpnp/dpnp_iface.py @@ -38,6 +38,7 @@ - The functions parameters check """ + # pylint: disable=protected-access import os diff --git a/dpnp/dpnp_iface_arraycreation.py b/dpnp/dpnp_iface_arraycreation.py index 50b425003764..8d4ebdd1a6c2 100644 --- a/dpnp/dpnp_iface_arraycreation.py +++ b/dpnp/dpnp_iface_arraycreation.py @@ -39,7 +39,6 @@ """ - # pylint: disable=duplicate-code import operator diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index 3cec24a44159..9df5278bd16b 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -39,7 +39,6 @@ """ - import math import operator import warnings @@ -3418,7 +3417,7 @@ def rot90(m, k=1, axes=(0, 1)): return dpnp.flip(dpnp.flip(m, axes[0]), axes[1]) axes_list = list(range(0, m_ndim)) - (axes_list[axes[0]], axes_list[axes[1]]) = ( + axes_list[axes[0]], axes_list[axes[1]] = ( axes_list[axes[1]], axes_list[axes[0]], ) diff --git a/dpnp/linalg/__init__.py b/dpnp/linalg/__init__.py index e04928393a8c..3fa27db33473 100644 --- a/dpnp/linalg/__init__.py +++ b/dpnp/linalg/__init__.py @@ -35,7 +35,6 @@ """ - from .dpnp_iface_linalg import ( LinAlgError, cholesky, diff --git a/dpnp/random/dpnp_random_state.py b/dpnp/random/dpnp_random_state.py index 560e2670932b..e49fe739aedd 100644 --- a/dpnp/random/dpnp_random_state.py +++ b/dpnp/random/dpnp_random_state.py @@ -36,7 +36,6 @@ """ - import dpctl.utils as dpu import numpy diff --git a/dpnp/scipy/linalg/__init__.py b/dpnp/scipy/linalg/__init__.py index a97f2cfb829c..3afc08a6fdb9 100644 --- a/dpnp/scipy/linalg/__init__.py +++ b/dpnp/scipy/linalg/__init__.py @@ -35,7 +35,6 @@ """ - from ._decomp_lu import lu_factor, lu_solve __all__ = [ diff --git a/dpnp/scipy/linalg/_decomp_lu.py b/dpnp/scipy/linalg/_decomp_lu.py index d2a58fba14d6..292d7fffe4b4 100644 --- a/dpnp/scipy/linalg/_decomp_lu.py +++ b/dpnp/scipy/linalg/_decomp_lu.py @@ -39,7 +39,6 @@ """ - import dpnp from dpnp.linalg.dpnp_utils_linalg import ( assert_stacked_2d, @@ -181,7 +180,7 @@ def lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True): """ - (lu, piv) = lu_and_piv + lu, piv = lu_and_piv dpnp.check_supported_arrays_type(lu, piv, b) assert_stacked_2d(lu) assert_stacked_square(lu) diff --git a/dpnp/scipy/linalg/_utils.py b/dpnp/scipy/linalg/_utils.py index be736e076d86..282c645d1095 100644 --- a/dpnp/scipy/linalg/_utils.py +++ b/dpnp/scipy/linalg/_utils.py @@ -37,7 +37,6 @@ """ - # pylint: disable=no-name-in-module # pylint: disable=protected-access diff --git a/dpnp/tests/third_party/cupy/core_tests/test_flags.py b/dpnp/tests/third_party/cupy/core_tests/test_flags.py index b2cc4fca59fb..3f416304a789 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_flags.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_flags.py @@ -29,9 +29,7 @@ def test_key_error(self): def test_repr(self): assert """ C_CONTIGUOUS : 1 F_CONTIGUOUS : 2 - OWNDATA : 3""" == repr( - self.flags - ) + OWNDATA : 3""" == repr(self.flags) @testing.parameterize( diff --git a/dpnp/tests/third_party/cupy/core_tests/test_function.py b/dpnp/tests/third_party/cupy/core_tests/test_function.py index 2943fc2bcf02..5480cdf6e126 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_function.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_function.py @@ -154,9 +154,7 @@ def test_custom_user_struct(self): offsets[3] = (unsigned long long)&ptr->d; offsets[4] = (unsigned long long)&ptr->e; }} -""".format( - struct_definition=struct_definition - ) +""".format(struct_definition=struct_definition) itemsize = cupy.ndarray(shape=(1,), dtype=numpy.uint64) sizes = cupy.ndarray(shape=(5,), dtype=numpy.uint64) @@ -213,9 +211,7 @@ def make_packed(basetype, N, itemsize): sum += s.e[0] + s.e[1] + s.e[2]; x[i] = a[i] + sum; }} -""".format( - struct_definition=struct_definition - ) +""".format(struct_definition=struct_definition) a_cpu = numpy.arange(24, dtype=numpy.float64) a = cupy.array(a_cpu) diff --git a/dpnp/tests/third_party/cupy/core_tests/test_include.py b/dpnp/tests/third_party/cupy/core_tests/test_include.py index 9c6372cf2bcd..a45d2b40cbf4 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_include.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_include.py @@ -18,25 +18,19 @@ #include """ -_code_nvcc = ( - _code_base - + """ +_code_nvcc = _code_base + """ #include int main() { return 0; } """ -) -_code_nvrtc = ( - _code_base - + """ +_code_nvrtc = _code_base + """ __device__ void kernel() { } """ -) @pytest.mark.skipif(cupy.cuda.runtime.is_hip, reason="for CUDA") diff --git a/dpnp/tests/third_party/cupy/test_init.py b/dpnp/tests/third_party/cupy/test_init.py index 0a841ba28b21..a4f1ad78f7f5 100644 --- a/dpnp/tests/third_party/cupy/test_init.py +++ b/dpnp/tests/third_party/cupy/test_init.py @@ -36,11 +36,9 @@ def _run_script(code): def _test_cupy_available(self): - returncode, stdoutdata, stderrdata = _run_script( - """ + returncode, stdoutdata, stderrdata = _run_script(""" import dpnp as cupy -print(cupy.is_available())""" - ) +print(cupy.is_available())""") assert returncode == 0, "stderr: {!r}".format(stderrdata) assert stdoutdata in (b"True\n", b"True\r\n", b"False\n", b"False\r\n") return stdoutdata == b"True\n" or stdoutdata == b"True\r\n" @@ -49,14 +47,12 @@ def _test_cupy_available(self): class TestImportError(unittest.TestCase): def test_import_error(self): - returncode, stdoutdata, stderrdata = _run_script( - """ + returncode, stdoutdata, stderrdata = _run_script(""" try: import dpnp as cupy except Exception as e: print(type(e).__name__) -""" - ) +""") assert returncode == 0, "stderr: {!r}".format(stderrdata) assert stdoutdata in (b"", b"RuntimeError\n") diff --git a/dpnp/tests/third_party/cupy/testing/_loops.py b/dpnp/tests/third_party/cupy/testing/_loops.py index 6a383780b9ca..63cd09147c4b 100644 --- a/dpnp/tests/third_party/cupy/testing/_loops.py +++ b/dpnp/tests/third_party/cupy/testing/_loops.py @@ -307,7 +307,7 @@ def decorator(impl): @_wraps_partial_xp(impl, name, sp_name, scipy_name) def test_func(*args, **kw): # Run cupy and numpy - (cupy_result, cupy_error, numpy_result, numpy_error) = ( + cupy_result, cupy_error, numpy_result, numpy_error = ( _call_func_numpy_cupy(impl, args, kw, name, sp_name, scipy_name) ) assert cupy_result is not None or cupy_error is not None @@ -344,9 +344,7 @@ def test_func(*args, **kw): raise AssertionError( """ndarrays of different dtypes are returned. cupy: {} -numpy: {}""".format( - cupy_r.dtype, numpy_r.dtype - ) +numpy: {}""".format(cupy_r.dtype, numpy_r.dtype) ) # Check contiguous @@ -902,7 +900,7 @@ def decorator(impl): @_wraps_partial_xp(impl, name, sp_name, scipy_name) def test_func(*args, **kw): # Run cupy and numpy - (cupy_result, cupy_error, numpy_result, numpy_error) = ( + cupy_result, cupy_error, numpy_result, numpy_error = ( _call_func_numpy_cupy(impl, args, kw, name, sp_name, scipy_name) ) @@ -958,7 +956,7 @@ def decorator(impl): @_wraps_partial_xp(impl, name, sp_name, scipy_name) def test_func(*args, **kw): # Run cupy and numpy - (cupy_result, cupy_error, numpy_result, numpy_error) = ( + cupy_result, cupy_error, numpy_result, numpy_error = ( _call_func_numpy_cupy(impl, args, kw, name, sp_name, scipy_name) ) diff --git a/dpnp/tests/third_party/cupy/testing/_pytest_impl.py b/dpnp/tests/third_party/cupy/testing/_pytest_impl.py index 97dfee5e174a..ecc4a6338eb5 100644 --- a/dpnp/tests/third_party/cupy/testing/_pytest_impl.py +++ b/dpnp/tests/third_party/cupy/testing/_pytest_impl.py @@ -19,14 +19,10 @@ def is_available(): def check_available(feature): if not is_available(): - raise RuntimeError( - """\ + raise RuntimeError("""\ cupy.testing: {} is not available. -Reason: {}: {}""".format( - feature, type(_error).__name__, _error - ) - ) +Reason: {}: {}""".format(feature, type(_error).__name__, _error)) if is_available(): diff --git a/examples/example1.py b/examples/example1.py index fdcbfbac9249..4d84c43c686c 100644 --- a/examples/example1.py +++ b/examples/example1.py @@ -37,7 +37,6 @@ """ - import time import dpctl diff --git a/examples/example2.py b/examples/example2.py index 853f879a7f11..eb856a2bed80 100644 --- a/examples/example2.py +++ b/examples/example2.py @@ -37,7 +37,6 @@ """ - import time import numpy diff --git a/examples/example4.py b/examples/example4.py index 0149c22f7ced..ea70ef18d612 100644 --- a/examples/example4.py +++ b/examples/example4.py @@ -34,7 +34,6 @@ """ - import numpy """