From 6adb1806655a7b5a81bc79e51eb82b2ae3847b28 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 16 Mar 2026 07:11:33 +0100 Subject: [PATCH 1/3] Bump pre-commit hooks --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 66ba8c23c9c..eb4591f960a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.10 + rev: v0.15.6 hooks: - id: ruff-check - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 + rev: 26.3.1 hooks: - id: black - repo: https://github.com/codespell-project/codespell - rev: v2.4.1 + rev: v2.4.2 hooks: - id: codespell additional_dependencies: @@ -42,5 +42,5 @@ repos: - git+https://github.com/dask/zict # Increase this value to clear the cache on GitHub actions if nothing else in this file -# has changed. See also same variable in .github/workflows/test.yaml +# has changed. See also same variable in .github/workflows/tests.yaml # CACHE_NUMBER: 1 From ac1890a3568aa25e56ae29f1784d7e04c8d47b33 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 16 Mar 2026 07:15:20 +0100 Subject: [PATCH 2/3] Run `pre-commit run -a black` --- distributed/cli/dask_worker.py | 2 +- distributed/comm/ucx.py | 6 ++--- distributed/nanny.py | 2 +- distributed/protocol/tests/test_cupy.py | 2 +- distributed/protocol/tests/test_numba.py | 2 +- distributed/scheduler.py | 6 ++--- distributed/shuffle/tests/test_rechunk.py | 2 +- distributed/tests/test_config.py | 12 +++------ distributed/tests/test_diskutils.py | 4 +-- distributed/tests/test_preload.py | 30 ++++++++--------------- distributed/tests/test_scheduler.py | 17 ++++--------- distributed/tests/test_utils_test.py | 12 +++------ docs/source/conf.py | 2 +- 13 files changed, 34 insertions(+), 65 deletions(-) diff --git a/distributed/cli/dask_worker.py b/distributed/cli/dask_worker.py index bf0f96420d0..4ba62426242 100755 --- a/distributed/cli/dask_worker.py +++ b/distributed/cli/dask_worker.py @@ -338,7 +338,7 @@ def main( # type: ignore[no-untyped-def] if contact_address: # we only need this to verify it is getting parsed - (_, _) = get_address_host_port(contact_address, strict=True) + _, _ = get_address_host_port(contact_address, strict=True) else: # if contact address is not present we use the listen_address for contact contact_address = listen_address diff --git a/distributed/comm/ucx.py b/distributed/comm/ucx.py index 4061701702f..0fed42c3294 100644 --- a/distributed/comm/ucx.py +++ b/distributed/comm/ucx.py @@ -10,14 +10,12 @@ def _raise_deprecated(): - message = textwrap.dedent( - """\ + message = textwrap.dedent("""\ The 'ucx' protocol was removed from Distributed because UCX-Py has been deprecated. To continue using protocol='ucx', please install 'distributed-ucxx' (conda-forge) or 'distributed-ucxx-cu[12,13]' (PyPI, selecting 12 for CUDA version 12.*, and 13 for CUDA version 13.*). - """ - ) + """) warnings.warn(message, FutureWarning) raise FutureWarning(message) diff --git a/distributed/nanny.py b/distributed/nanny.py index b968ab79e51..4d54666b63c 100644 --- a/distributed/nanny.py +++ b/distributed/nanny.py @@ -594,7 +594,7 @@ def close_gracefully(self, reason: str = "nanny-close-gracefully") -> None: "Closing Nanny gracefully at %r. Reason: %s", self.address_safe, reason ) - async def close( # type:ignore[override] + async def close( # type: ignore[override] self, timeout: float = 5, reason: str = "nanny-close" ) -> Literal["OK"]: """ diff --git a/distributed/protocol/tests/test_cupy.py b/distributed/protocol/tests/test_cupy.py index a0b0c2b6846..9c074b89cde 100644 --- a/distributed/protocol/tests/test_cupy.py +++ b/distributed/protocol/tests/test_cupy.py @@ -57,7 +57,7 @@ def test_serialize_cupy_from_rmm(size): x_np = np.arange(size, dtype="u1") x_np_desc = x_np.__array_interface__ - (x_np_ptr, _) = x_np_desc["data"] + x_np_ptr, _ = x_np_desc["data"] (x_np_size,) = x_np_desc["shape"] x = rmm.DeviceBuffer(ptr=x_np_ptr, size=x_np_size) diff --git a/distributed/protocol/tests/test_numba.py b/distributed/protocol/tests/test_numba.py index a5d86d8e651..02bf2208587 100644 --- a/distributed/protocol/tests/test_numba.py +++ b/distributed/protocol/tests/test_numba.py @@ -47,7 +47,7 @@ def test_serialize_numba_from_rmm(size): x_np = np.arange(size, dtype="u1") x_np_desc = x_np.__array_interface__ - (x_np_ptr, _) = x_np_desc["data"] + x_np_ptr, _ = x_np_desc["data"] (x_np_size,) = x_np_desc["shape"] x = rmm.DeviceBuffer(ptr=x_np_ptr, size=x_np_size) diff --git a/distributed/scheduler.py b/distributed/scheduler.py index 00d8e525b56..d055d91f41c 100644 --- a/distributed/scheduler.py +++ b/distributed/scheduler.py @@ -5045,8 +5045,7 @@ def _generate_taskstates( "releasing all the data before resubmitting another " "computation. More details and help can be found at " "https://github.com/dask/dask/issues/9888. " - + textwrap.dedent( - f""" + + textwrap.dedent(f""" Debugging information --------------------- old task state: {ts.state} @@ -5054,8 +5053,7 @@ def _generate_taskstates( new run_spec: {dsk[k]!r} old dependencies: {deps_lhs} new dependencies: {deps_rhs} - """ - ) + """) ) else: logger.debug( diff --git a/distributed/shuffle/tests/test_rechunk.py b/distributed/shuffle/tests/test_rechunk.py index d27f73192a9..9edb580505b 100644 --- a/distributed/shuffle/tests/test_rechunk.py +++ b/distributed/shuffle/tests/test_rechunk.py @@ -384,7 +384,7 @@ async def test_rechunk_expand2(c, s, *ws): -------- dask.array.tests.test_rechunk.test_rechunk_expand2 """ - (a, b) = (3, 2) + a, b = (3, 2) orig = np.random.default_rng().uniform(0, 1, a**b).reshape((a,) * b) for off, off2 in product(range(1, a - 1), range(1, a - 1)): old = ((a - off, off),) * b diff --git a/distributed/tests/test_config.py b/distributed/tests/test_config.py index 1d6f918523c..b7bf97ef92c 100644 --- a/distributed/tests/test_config.py +++ b/distributed/tests/test_config.py @@ -200,14 +200,12 @@ def test_logging_extended(): def test_default_logging_does_not_override_basic_config(): - code = textwrap.dedent( - """\ + code = textwrap.dedent("""\ import logging logging.basicConfig() import distributed logging.getLogger("distributed").warning("hello") - """ - ) + """) proc = subprocess.run( [sys.executable, "-c", code], check=True, capture_output=True, encoding="utf8" ) @@ -216,15 +214,13 @@ def test_default_logging_does_not_override_basic_config(): def test_basic_config_does_not_override_default_logging(): - code = textwrap.dedent( - """\ + code = textwrap.dedent("""\ import logging import distributed logging.basicConfig() logging.getLogger("distributed").warning("hello") - """ - ) + """) proc = subprocess.run( [sys.executable, "-c", code], check=True, capture_output=True, encoding="utf8" ) diff --git a/distributed/tests/test_diskutils.py b/distributed/tests/test_diskutils.py index 048a422f4cb..8a559de68a0 100644 --- a/distributed/tests/test_diskutils.py +++ b/distributed/tests/test_diskutils.py @@ -122,9 +122,7 @@ def test_workspace_process_crash(tmp_path): sys.stdout.flush() time.sleep(100) - """ % dict( - base_dir=base_dir - ) + """ % dict(base_dir=base_dir) p = subprocess.Popen( [sys.executable, "-c", code], diff --git a/distributed/tests/test_preload.py b/distributed/tests/test_preload.py index c0dcbc2f940..b1b7ce84df4 100644 --- a/distributed/tests/test_preload.py +++ b/distributed/tests/test_preload.py @@ -228,12 +228,10 @@ async def test_scheduler_startup_nanny(s): @gen_test() async def test_web_preload_worker(): port = open_port() - data = dedent( - f"""\ + data = dedent(f"""\ import dask dask.config.set(scheduler_address="tcp://127.0.0.1:{port}") - """ - ).encode() + """).encode() with mock.patch( "urllib3.PoolManager.request", **{"return_value.data": data}, @@ -252,16 +250,14 @@ async def test_web_preload_worker(): ) @gen_cluster(nthreads=[]) async def test_client_preload_text(s): - text = dedent( - """\ + text = dedent("""\ def dask_setup(client): client.foo = "setup" def dask_teardown(client): client.foo = "teardown" - """ - ) + """) async with Client(address=s.address, asynchronous=True, preload=text) as c: assert c.foo == "setup" assert c.foo == "teardown" @@ -269,16 +265,14 @@ def dask_teardown(client): @gen_cluster(nthreads=[]) async def test_client_preload_config(s): - text = dedent( - """\ + text = dedent("""\ def dask_setup(client): client.foo = "setup" def dask_teardown(client): client.foo = "teardown" - """ - ) + """) with dask.config.set({"distributed.client.preload": [text]}): async with Client(address=s.address, asynchronous=True) as c: assert c.foo == "setup" @@ -291,16 +285,14 @@ def dask_teardown(client): ) @gen_cluster(nthreads=[]) async def test_client_preload_click(s): - text = dedent( - """\ + text = dedent("""\ import click @click.command() @click.argument("value") def dask_setup(client, value): client.foo = value - """ - ) + """) value = "setup" async with Client( address=s.address, asynchronous=True, preload=text, preload_argv=[[value]] @@ -387,16 +379,14 @@ def dask_teardown(worker): @gen_cluster(nthreads=[]) async def test_client_preload_config_click(s): - text = dedent( - """\ + text = dedent("""\ import click @click.command() @click.argument("value") def dask_setup(client, value): client.foo = value - """ - ) + """) value = "setup" with dask.config.set( { diff --git a/distributed/tests/test_scheduler.py b/distributed/tests/test_scheduler.py index 4b9d917df9c..e2f714e1c68 100644 --- a/distributed/tests/test_scheduler.py +++ b/distributed/tests/test_scheduler.py @@ -2396,7 +2396,7 @@ def qux(x): @gen_cluster(client=True) async def test_collect_versions(c, s, a, b): cs = s.clients[c.id] - (w1, w2) = s.workers.values() + w1, w2 = s.workers.values() assert cs.versions assert w1.versions assert w2.versions @@ -3462,18 +3462,13 @@ def test_memorystate(): with pytest.warns(FutureWarning): assert m.managed_in_memory == m.managed - assert ( - repr(m) - == dedent( - """ + assert repr(m) == dedent(""" Process memory (RSS) : 100 B - managed by Dask : 68 B - unmanaged (old) : 15 B - unmanaged (recent): 17 B Spilled to disk : 12 B - """ - ).lstrip() - ) + """).lstrip() def test_memorystate_sum(): @@ -3879,14 +3874,12 @@ async def test_rebalance_raises_missing_data3(c, s, a, b, explicit): futures = await c.scatter(range(100), workers=[a.address]) if explicit: - pytest.xfail( - reason="""Freeing keys and gathering data is using different + pytest.xfail(reason="""Freeing keys and gathering data is using different channels (stream vs explicit RPC). Therefore, the partial-fail is very timing sensitive and subject to a race condition. This test assumes that the data is freed before the rebalance get_data requests come in but merely deleting - the futures is not sufficient to guarantee this""" - ) + the futures is not sufficient to guarantee this""") keys = [f.key for f in futures] del futures out = await s.rebalance(keys=keys) diff --git a/distributed/tests/test_utils_test.py b/distributed/tests/test_utils_test.py index 62f0bf2f8d6..3b78c25e2ff 100755 --- a/distributed/tests/test_utils_test.py +++ b/distributed/tests/test_utils_test.py @@ -818,8 +818,7 @@ def test_popen_write_during_terminate_deadlock(): [ sys.executable, "-c", - textwrap.dedent( - """ + textwrap.dedent(""" import signal import threading @@ -833,8 +832,7 @@ def cb(signum, frame): signal.signal(signal.SIGINT, cb) print('ready', flush=True) e.wait() - """ - ), + """), ], capture_output=True, ) as proc: @@ -849,8 +847,7 @@ def test_popen_timeout(capsys): [ sys.executable, "-c", - textwrap.dedent( - """ + textwrap.dedent(""" import signal import sys import time @@ -862,8 +859,7 @@ def test_popen_timeout(capsys): while True: time.sleep(0.1) print("slept", flush=True) - """ - ), + """), ], capture_output=True, terminate_timeout=1, diff --git a/docs/source/conf.py b/docs/source/conf.py index 2234bf4937e..3c0155a592e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -468,7 +468,7 @@ def get_members(app, obj, typ, include_public=None): def run(self): clazz = str(self.arguments[0]) - (module_name, class_name) = clazz.rsplit(".", 1) + module_name, class_name = clazz.rsplit(".", 1) m = __import__(module_name, globals(), locals(), [class_name]) c = getattr(m, class_name) app = self.state.document.settings.env.app From 8d35cff3e15462812e66fea15b704cdde1b86fbf Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 16 Mar 2026 07:21:09 +0100 Subject: [PATCH 3/3] =?UTF-8?q?pre-commit=20=E2=86=92=20prek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .github/workflows/ci-pre-commit.yml | 7 ++----- continuous_integration/environment-3.10.yaml | 2 +- continuous_integration/environment-3.11.yaml | 2 +- continuous_integration/environment-3.12.yaml | 2 +- continuous_integration/environment-3.13.yaml | 2 +- continuous_integration/environment-3.14.yaml | 2 +- 7 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f8e3506db68..8af6ef473df 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ Closes #xxxx - [ ] Tests added / passed -- [ ] Passes `pre-commit run --all-files` +- [ ] Passes `prek run --all-files` diff --git a/.github/workflows/ci-pre-commit.yml b/.github/workflows/ci-pre-commit.yml index 00540692dd0..b928c315b73 100644 --- a/.github/workflows/ci-pre-commit.yml +++ b/.github/workflows/ci-pre-commit.yml @@ -8,11 +8,8 @@ on: jobs: checks: - name: pre-commit hooks + name: prek hooks runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.3 - - uses: actions/setup-python@v6 - with: - python-version: '3.12' - - uses: pre-commit/action@v3.0.1 + - uses: j178/prek-action@v1.1.1 diff --git a/continuous_integration/environment-3.10.yaml b/continuous_integration/environment-3.10.yaml index f3914e8ae9a..ff40caa0416 100644 --- a/continuous_integration/environment-3.10.yaml +++ b/continuous_integration/environment-3.10.yaml @@ -28,7 +28,7 @@ dependencies: - msgpack-python - netcdf4 - paramiko - - pre-commit + - prek - prometheus_client - psutil - pyarrow diff --git a/continuous_integration/environment-3.11.yaml b/continuous_integration/environment-3.11.yaml index 256999899d1..3890d55bbe2 100644 --- a/continuous_integration/environment-3.11.yaml +++ b/continuous_integration/environment-3.11.yaml @@ -25,7 +25,7 @@ dependencies: - msgpack-python - netcdf4 - paramiko - - pre-commit + - prek - prometheus_client - psutil - pyarrow=16.0 diff --git a/continuous_integration/environment-3.12.yaml b/continuous_integration/environment-3.12.yaml index e33c82a30e9..1cfca2c8381 100644 --- a/continuous_integration/environment-3.12.yaml +++ b/continuous_integration/environment-3.12.yaml @@ -25,7 +25,7 @@ dependencies: - msgpack-python - netcdf4 - paramiko - - pre-commit + - prek - prometheus_client - psutil - pyarrow diff --git a/continuous_integration/environment-3.13.yaml b/continuous_integration/environment-3.13.yaml index 3e22fa4b466..d63ee9df48f 100644 --- a/continuous_integration/environment-3.13.yaml +++ b/continuous_integration/environment-3.13.yaml @@ -24,7 +24,7 @@ dependencies: - msgpack-python - netcdf4 - paramiko - - pre-commit + - prek - prometheus_client - psutil - pyarrow diff --git a/continuous_integration/environment-3.14.yaml b/continuous_integration/environment-3.14.yaml index b39f35c9d08..129f1321f6a 100644 --- a/continuous_integration/environment-3.14.yaml +++ b/continuous_integration/environment-3.14.yaml @@ -24,7 +24,7 @@ dependencies: - msgpack-python - netcdf4 - paramiko - - pre-commit + - prek - prometheus_client - psutil - pyarrow