Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ repos:
rev: v0.14.5
hooks:
- id: ruff-check
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
language_version: python3
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.11.0
hooks:
Expand Down
6 changes: 2 additions & 4 deletions distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@
from pickle import PickleBuffer
from time import sleep
from types import ModuleType
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, ClassVar, TypeVar, overload
from typing import Any as AnyType
from typing import ClassVar, TypeVar, overload

import psutil
import tblib.pickling_support
Expand All @@ -67,9 +66,8 @@
from tornado.ioloop import IOLoop

import dask
from dask.utils import _deprecated
from dask.utils import _deprecated, key_split
from dask.utils import ensure_bytes as _ensure_bytes
from dask.utils import key_split
from dask.utils import parse_timedelta as _parse_timedelta
from dask.widgets import get_template

Expand Down
2 changes: 1 addition & 1 deletion distributed/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
InvalidTransition,
SecedeEvent,
StateMachineEvent,
WorkerState,
)
from distributed.worker_state_machine import TaskState as WorkerTaskState
from distributed.worker_state_machine import WorkerState

try:
import dask.array # register config
Expand Down
2 changes: 1 addition & 1 deletion distributed/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
context_meter_to_server_digest,
error_message,
pingpong,
send_recv,
)
from distributed.core import rpc as RPCType
from distributed.core import send_recv
from distributed.diagnostics import nvml, rmm
from distributed.diagnostics.plugin import WorkerPlugin, _get_plugin_name
from distributed.diskutils import WorkSpace
Expand Down
15 changes: 6 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ line-length = 120
extend-select = [
"B",
"TID",
"I",
"UP",
]
ignore = [
Expand All @@ -101,15 +102,11 @@ ignore = [
"distributed/shuffle/tests/test_shuffle.py" = ["F601"]
"distributed/utils.py" = ["F821"]

[tool.isort]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "DISTRIBUTED", "FIRSTPARTY", "LOCALFOLDER"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like ruff supports sections, can you make sure we are configuring things the same way? We use these sections specifically to improve readability.

I would suggest going through each setting we had with isort and checking if you can replicate the same setting with ruff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like for dask, I focused on actual changes in the source code instead of reviewing individual options in detail. It seems to work well in both repositories.

I can review the options more in detail. I seem to recall that most of them are identical to the defaults, which is why I removed them. I'll have a look.

Copy link
Contributor Author

@DimitriPapadopoulos DimitriPapadopoulos Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tool.isort.sections defines all sections isort uses by default:

from typing import Tuple

FUTURE: str = "FUTURE"

STDLIB: str = "STDLIB"

THIRDPARTY: str = "THIRDPARTY"

FIRSTPARTY: str = "FIRSTPARTY"

LOCALFOLDER: str = "LOCALFOLDER"

DEFAULT: Tuple[str, ...] = (FUTURE, STDLIB, THIRDPARTY, FIRSTPARTY, LOCALFOLDER)

The main difference with the default value is the addition of DISTRIBUTED.

- "FUTURE", "STDLIB", "THIRDPARTY", "DISTRIBUTED", "FIRSTPARTY", "LOCALFOLDER"
+ "FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"

where DISTRIBUTED is defined as:

known_distributed = ["dask", "zict"]

which I guess forces to identify dask, distributed and zict as being part of the current python project. This avoids the empty line between dask and distributed imports puts dask and zict imports in a section of their own, between third-party and first-party distributed.

My thoughts about it:

  • Why care about such details and not use the defaults?
  • Actually, why avoid the line between dask and distributed imports? I don't see how that's a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevertheless, I have added this section in ruff settings:

"distributed" = ["dask", "zict"]

I'll have a fresh look at dask taking into account this change.

profile = "black"
skip_gitignore = true
force_to_top = ["true"]
default_section = "THIRDPARTY"
Comment on lines -106 to -109
Copy link
Contributor Author

@DimitriPapadopoulos DimitriPapadopoulos Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously, profile = "black" is not needed any more.

I think that skip_gitignore has no ruff equivalent, and that it's basically a non-issue.

Option force_to_top seems misused here.

known_first_party = ["distributed"]
known_distributed = ["dask", "zict"]
add_imports = ["from __future__ import annotations"]
[tool.ruff.lint.isort]
section-order = ["future", "standard-library", "third-party", "distributed", "first-party", "local-folder"]

[tool.ruff.lint.isort.sections]
"distributed" = ["dask", "zict"]

[tool.setuptools_scm]
version_file = "distributed/_version.py"
Expand Down
Loading