Skip to content

Commit

Permalink
[Dependencies] Remove typing_extensions (ray-project#40336)
Browse files Browse the repository at this point in the history
Now that we drop Python 3.7 support for Ray 2.8, we can remove the `typing_extensions` dependency.
  • Loading branch information
pcmoritz committed Oct 17, 2023
1 parent 4113ab4 commit dd6eb71
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 71 deletions.
1 change: 0 additions & 1 deletion doc/source/ray-overview/pip_freeze_ray-ml-py39-cpu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ triton==2.0.0
tune-sklearn @ git+https://github.com/ray-project/tune-sklearn@6e813e18fb43156d32f0958794881c7c12d14f17
typeguard==2.13.3
typer==0.9.0
typing_extensions==4.5.0
tzdata==2023.3
uri-template==1.3.0
uritemplate==3.0.1
Expand Down
1 change: 0 additions & 1 deletion doc/source/ray-overview/pip_freeze_ray-py39-cpu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ tensorboardX==2.6
tifffile==2023.7.10
tqdm @ file:https:///croot/tqdm_1679561862951/work
typer==0.9.0
typing_extensions==4.5.0
tzdata==2023.3
uritemplate==3.0.1
urllib3 @ file:https:///croot/urllib3_1686163155763/work
Expand Down
5 changes: 1 addition & 4 deletions python/ray/_private/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
import colorama
import setproctitle

if sys.version_info >= (3, 8):
from typing import Literal, Protocol
else:
from typing_extensions import Literal, Protocol
from typing import Literal, Protocol

import ray
import ray._private.node
Expand Down
8 changes: 2 additions & 6 deletions python/ray/data/block.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import collections
import os
import sys
import time
from dataclasses import dataclass
from typing import (
Expand All @@ -9,7 +8,9 @@
Dict,
Iterator,
List,
Literal,
Optional,
Protocol,
Tuple,
TypeVar,
Union,
Expand All @@ -30,11 +31,6 @@
except ImportError:
resource = None

if sys.version_info >= (3, 8):
from typing import Literal, Protocol
else:
from typing_extensions import Literal, Protocol

if TYPE_CHECKING:
import pandas
import pyarrow
Expand Down
7 changes: 1 addition & 6 deletions python/ray/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import html
import itertools
import logging
import sys
import time
from typing import (
TYPE_CHECKING,
Expand All @@ -14,6 +13,7 @@
Iterable,
Iterator,
List,
Literal,
Mapping,
Optional,
Tuple,
Expand Down Expand Up @@ -131,11 +131,6 @@
from ray.widgets import Template
from ray.widgets.util import repr_with_fallback

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if TYPE_CHECKING:
import dask
import mars
Expand Down
6 changes: 1 addition & 5 deletions python/ray/data/datasource/file_based_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Iterable,
Iterator,
List,
Literal,
Optional,
Tuple,
TypeVar,
Expand Down Expand Up @@ -45,11 +46,6 @@
)
from ray.util.annotations import DeveloperAPI, PublicAPI

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if TYPE_CHECKING:
import pandas as pd
import pyarrow
Expand Down
8 changes: 1 addition & 7 deletions python/ray/data/datasource/parquet_datasource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import sys
from typing import TYPE_CHECKING, Callable, Iterator, List, Optional, Union
from typing import TYPE_CHECKING, Callable, Iterator, List, Literal, Optional, Union

import numpy as np

Expand All @@ -23,11 +22,6 @@
from ray.data.datasource.parquet_base_datasource import ParquetBaseDatasource
from ray.util.annotations import PublicAPI

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if TYPE_CHECKING:
import pyarrow
from pyarrow.dataset import ParquetFileFragment
Expand Down
8 changes: 1 addition & 7 deletions python/ray/data/preprocessors/batch_mapper.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import sys
import warnings
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Union
from typing import TYPE_CHECKING, Any, Callable, Dict, Literal, Optional, Union

import numpy as np

from ray.air.util.data_batch_conversion import BatchFormat
from ray.data.preprocessor import Preprocessor
from ray.util.annotations import Deprecated

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if TYPE_CHECKING:
import pandas

Expand Down
7 changes: 1 addition & 6 deletions python/ray/data/read_api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import collections
import logging
import os
import sys
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
List,
Literal,
Optional,
Tuple,
TypeVar,
Expand Down Expand Up @@ -83,11 +83,6 @@
from ray.util.annotations import Deprecated, DeveloperAPI, PublicAPI
from ray.util.scheduling_strategies import NodeAffinitySchedulingStrategy

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal

if TYPE_CHECKING:
import dask
import datasets
Expand Down
8 changes: 1 addition & 7 deletions python/ray/train/_internal/data_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
from typing import Dict, List, Optional, Union
from typing import Dict, List, Literal, Optional, Union

import ray
from ray.actor import ActorHandle
Expand All @@ -10,11 +9,6 @@
from ray.train.constants import TRAIN_DATASET_KEY # noqa
from ray.util.annotations import DeveloperAPI, PublicAPI

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal


@PublicAPI(stability="stable")
class DataConfig:
Expand Down
7 changes: 1 addition & 6 deletions python/ray/util/state/custom_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

from ray.core.generated.common_pb2 import (
TaskStatus,
TaskType,
Expand All @@ -13,10 +11,7 @@
)
from ray.dashboard.memory_utils import ReferenceType

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing import Literal


ACTOR_STATUS = [
Expand Down
1 change: 0 additions & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ grpcio == 1.54.2; sys_platform == "darwin"
grpcio >= 1.54.2; sys_platform != "darwin"
numpy>=1.16; python_version < '3.9'
numpy>=1.19.3; python_version >= '3.9'
typing_extensions; python_version < '3.8'

pyarrow >= 6.0.1; platform_system != "Windows"
pyarrow >= 6.0.1, < 7.0.0; platform_system == "Windows"
Expand Down
3 changes: 0 additions & 3 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,6 @@ def get_packages(self):
"aiosignal",
"frozenlist",
"requests",
# Light weight requirement, can be replaced with "typing" once
# we deprecate Python 3.7 (this will take a while).
"typing_extensions; python_version < '3.8'",
]


Expand Down
6 changes: 1 addition & 5 deletions release/nightly_tests/dataset/iter_batches_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import sys
from typing import Optional

import ray
from ray.data.dataset import Dataset

from benchmark import Benchmark

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing import Literal


def iter_batches(
Expand Down
6 changes: 1 addition & 5 deletions release/nightly_tests/dataset/map_batches_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from typing import Optional, Union
import numpy as np

Expand All @@ -8,10 +7,7 @@

from benchmark import Benchmark

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing import Literal


def map_batches(
Expand Down
2 changes: 1 addition & 1 deletion release/ray_release/configs/global_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

import yaml
from typing_extensions import TypedDict
from typing import TypedDict


class GlobalConfig(TypedDict):
Expand Down

0 comments on commit dd6eb71

Please sign in to comment.