Skip to content

Commit a9dab3a

Browse files
[CI] Convert isort config to ruff config (#52869)
Convert isort config in .isort.cfg to ruff config in pyproject.toml. Conversion strategy: known_local_folder -> known-local-folder known_third_party -> known-third-party known_afterray -> Created a new section afterray sections -> section_order skip_glob -> If already exists in tool.ruff.extend-exclude then do nothing. Otherwise add a rule to per-file-ignores to ignore the I rule. Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com> Co-authored-by: Lonnie Liu <95255098+aslonnie@users.noreply.github.com>
1 parent 2c1b283 commit a9dab3a

File tree

15 files changed

+47
-52
lines changed

15 files changed

+47
-52
lines changed

.isort.cfg

Lines changed: 0 additions & 27 deletions
This file was deleted.

pyproject.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,36 @@ avoid-escape = false
4545

4646
[tool.ruff.lint.isort]
4747
combine-as-imports = true
48+
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder", "afterray"]
49+
known-local-folder = ["ray"]
50+
known-third-party = ["grpc"]
51+
52+
[tool.ruff.lint.isort.sections]
53+
afterray = ["psutil", "setproctitle"]
54+
55+
# Some of the directories need to be kept in the blacklist for isort ("I" rule):
56+
# python/ray/cloudpickle/*
57+
# doc/*
58+
# python/ray/__init__.py
59+
# python/ray/setup-dev.py
60+
# For the rest we will gradually remove them from the blacklist as we
61+
# reformat the code to follow the style guide.
62+
[tool.ruff.lint.per-file-ignores]
63+
"doc/*" = ["I"]
64+
"python/ray/__init__.py" = ["I"]
65+
"python/ray/setup-dev.py" = ["I"]
66+
"python/ray/cloudpickle/*" = ["I"]
67+
"python/ray/dag/*.py" = ["I"]
68+
"ci/*" = ["I"]
69+
"python/ray/includes/*" = ["I"]
70+
"python/ray/internal/*" = ["I"]
71+
"python/ray/ray_operator/*" = ["I"]
72+
"python/ray/scripts/*" = ["I"]
73+
"python/ray/serve/generated/serve_pb2.py" = ["I"]
74+
"python/ray/streaming/*" = ["I"]
75+
"python/ray/tests/*" = ["I"]
76+
"python/ray/util/*" = ["I"]
77+
"python/ray/workers/*" = ["I"]
78+
"python/ray/workflow/*" = ["I"]
79+
"rllib/*" = ["I"]
80+
"release/*" = ["I"]

python/ray/data/_internal/datasource/tfrecords_datasink.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
import numpy as np
55

6+
from .tfrecords_datasource import _get_single_true_type
67
from ray.data._internal.util import _check_import
78
from ray.data.block import BlockAccessor
89
from ray.data.datasource.file_datasink import BlockBasedFileDatasink
910

10-
from .tfrecords_datasource import _get_single_true_type
11-
1211
if TYPE_CHECKING:
1312
import pyarrow
1413
import tensorflow as tf

python/ray/data/_internal/execution/autoscaler/default_autoscaler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
from typing import TYPE_CHECKING, Dict, Optional, Tuple
55

66
import ray
7+
from .autoscaler import Autoscaler
8+
from .autoscaling_actor_pool import AutoscalingActorPool
79
from ray.data._internal.execution.autoscaling_requester import (
810
get_or_create_autoscaling_requester_actor,
911
)
1012
from ray.data._internal.execution.interfaces.execution_options import ExecutionResources
1113

12-
from .autoscaler import Autoscaler
13-
from .autoscaling_actor_pool import AutoscalingActorPool
14-
1514
if TYPE_CHECKING:
1615
from ray.data._internal.execution.interfaces import PhysicalOperator
1716
from ray.data._internal.execution.resource_manager import ResourceManager

python/ray/data/_internal/execution/backpressure_policy/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import TYPE_CHECKING
22

33
import ray
4-
54
from .backpressure_policy import BackpressurePolicy
65
from .concurrency_cap_backpressure_policy import ConcurrencyCapBackpressurePolicy
76

python/ray/data/_internal/execution/backpressure_policy/concurrency_cap_backpressure_policy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import logging
22
from typing import TYPE_CHECKING
33

4+
from .backpressure_policy import BackpressurePolicy
45
from ray.data._internal.execution.operators.task_pool_map_operator import (
56
TaskPoolMapOperator,
67
)
78

8-
from .backpressure_policy import BackpressurePolicy
9-
109
if TYPE_CHECKING:
1110
from ray.data._internal.execution.interfaces.physical_operator import (
1211
PhysicalOperator,

python/ray/data/_internal/execution/interfaces/execution_options.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import os
22
from typing import Dict, List, Optional, Union
33

4+
from .common import NodeIdStr
45
from ray.data._internal.execution.util import memory_string
56
from ray.util.annotations import DeveloperAPI
67

7-
from .common import NodeIdStr
8-
98

109
class ExecutionResources:
1110
"""Specifies resources usage or resource limits for execution.

python/ray/data/_internal/execution/interfaces/executor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from abc import ABC, abstractmethod
22
from typing import ContextManager, Iterator, Optional
33

4-
from ray.data._internal.stats import DatasetStats
5-
64
from .execution_options import ExecutionOptions
75
from .physical_operator import PhysicalOperator
86
from .ref_bundle import RefBundle
7+
from ray.data._internal.stats import DatasetStats
98

109

1110
class OutputIterator(Iterator[RefBundle], ABC):

python/ray/data/_internal/execution/interfaces/physical_operator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
66

77
import ray
8+
from .ref_bundle import RefBundle
89
from ray._raylet import ObjectRefGenerator
910
from ray.data._internal.execution.autoscaler.autoscaling_actor_pool import (
1011
AutoscalingActorPool,
@@ -19,8 +20,6 @@
1920
from ray.data._internal.stats import StatsDict, Timer
2021
from ray.data.context import DataContext
2122

22-
from .ref_bundle import RefBundle
23-
2423
logger = logging.getLogger(__name__)
2524

2625

python/ray/data/_internal/execution/interfaces/ref_bundle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
from typing import Dict, Iterator, List, Optional, Tuple
44

55
import ray
6+
from .common import NodeIdStr
67
from ray.data._internal.memory_tracing import trace_deallocation
78
from ray.data.block import Block, BlockMetadata
89
from ray.data.context import DataContext
910
from ray.types import ObjectRef
1011

11-
from .common import NodeIdStr
12-
1312

1413
@dataclass
1514
class RefBundle:

0 commit comments

Comments
 (0)