diff --git a/packages/bigframes/bigframes/core/utils.py b/packages/bigframes/bigframes/core/utils.py index b219335a516e..9492ca497839 100644 --- a/packages/bigframes/bigframes/core/utils.py +++ b/packages/bigframes/bigframes/core/utils.py @@ -16,12 +16,11 @@ import re import typing import warnings -from typing import Hashable, Iterable, List +from typing import Hashable, Iterable, List, TypeGuard import bigframes_vendored.pandas.io.common as vendored_pandas_io_common import numpy as np import pandas as pd -import typing_extensions import bigframes.exceptions as bfe @@ -29,7 +28,7 @@ UNNAMED_INDEX_ID = "bigframes_unnamed_index" -def is_gcs_path(value) -> typing_extensions.TypeGuard[str]: +def is_gcs_path(value) -> TypeGuard[str]: return isinstance(value, str) and value.startswith("gs://") @@ -43,11 +42,11 @@ def get_axis_number(axis: typing.Union[str, int]) -> typing.Literal[0, 1]: def is_list_like( obj: typing.Any, allow_sets: bool = True -) -> typing_extensions.TypeGuard[typing.Sequence]: +) -> TypeGuard[typing.Sequence]: return pd.api.types.is_list_like(obj, allow_sets=allow_sets) -def is_dict_like(obj: typing.Any) -> typing_extensions.TypeGuard[typing.Mapping]: +def is_dict_like(obj: typing.Any) -> TypeGuard[typing.Mapping]: return pd.api.types.is_dict_like(obj) diff --git a/packages/bigframes/bigframes/series.py b/packages/bigframes/bigframes/series.py index 0091d0a34b6c..9d61cc9778fe 100644 --- a/packages/bigframes/bigframes/series.py +++ b/packages/bigframes/bigframes/series.py @@ -33,6 +33,7 @@ Optional, Sequence, Tuple, + TypeGuard, TypeVar, Union, cast, @@ -45,7 +46,6 @@ import numpy import pandas import pyarrow as pa -import typing_extensions from pandas.api import extensions as pd_ext import bigframes.core @@ -2825,5 +2825,5 @@ def _throw_if_null_index(self, opname: __builtins__.str): ) -def _is_list_like(obj: typing.Any) -> typing_extensions.TypeGuard[typing.Sequence]: +def _is_list_like(obj: typing.Any) -> TypeGuard[typing.Sequence]: return pandas.api.types.is_list_like(obj) diff --git a/packages/bigframes/third_party/bigframes_vendored/ibis/common/bases.py b/packages/bigframes/third_party/bigframes_vendored/ibis/common/bases.py index 2d5d798c318f..17dbc683c572 100644 --- a/packages/bigframes/third_party/bigframes_vendored/ibis/common/bases.py +++ b/packages/bigframes/third_party/bigframes_vendored/ibis/common/bases.py @@ -3,6 +3,7 @@ from __future__ import annotations import collections.abc +import sys from abc import abstractmethod from typing import TYPE_CHECKING, Any from weakref import WeakValueDictionary @@ -10,7 +11,10 @@ if TYPE_CHECKING: from collections.abc import Mapping - from typing_extensions import Self + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self class AbstractMeta(type): diff --git a/packages/bigframes/third_party/bigframes_vendored/ibis/common/collections.py b/packages/bigframes/third_party/bigframes_vendored/ibis/common/collections.py index 718b94235dd7..4740a47900db 100644 --- a/packages/bigframes/third_party/bigframes_vendored/ibis/common/collections.py +++ b/packages/bigframes/third_party/bigframes_vendored/ibis/common/collections.py @@ -3,6 +3,7 @@ from __future__ import annotations import collections.abc +import sys from abc import abstractmethod from itertools import tee from typing import TYPE_CHECKING, Any, Generic, TypeVar @@ -12,7 +13,10 @@ from public import public if TYPE_CHECKING: - from typing_extensions import Self + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self K = TypeVar("K", bound=collections.abc.Hashable) V = TypeVar("V") diff --git a/packages/bigframes/third_party/bigframes_vendored/ibis/common/graph.py b/packages/bigframes/third_party/bigframes_vendored/ibis/common/graph.py index 9bf13e93ecf6..7e9d4eae02e7 100644 --- a/packages/bigframes/third_party/bigframes_vendored/ibis/common/graph.py +++ b/packages/bigframes/third_party/bigframes_vendored/ibis/common/graph.py @@ -5,6 +5,7 @@ from __future__ import annotations import itertools +import sys from abc import abstractmethod from collections import deque from collections.abc import Callable, Iterable, Iterator, KeysView, Mapping, Sequence @@ -16,7 +17,10 @@ from bigframes_vendored.ibis.util import experimental, promote_list if TYPE_CHECKING: - from typing_extensions import Self + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self N = TypeVar("N") diff --git a/packages/bigframes/third_party/bigframes_vendored/ibis/common/grounds.py b/packages/bigframes/third_party/bigframes_vendored/ibis/common/grounds.py index 874e18c40574..64a4f6502418 100644 --- a/packages/bigframes/third_party/bigframes_vendored/ibis/common/grounds.py +++ b/packages/bigframes/third_party/bigframes_vendored/ibis/common/grounds.py @@ -2,6 +2,7 @@ from __future__ import annotations import contextlib +import sys from copy import copy from typing import Any, ClassVar, Union, get_origin @@ -23,7 +24,11 @@ from bigframes_vendored.ibis.common.collections import FrozenDict # noqa: TCH001 from bigframes_vendored.ibis.common.patterns import Pattern from bigframes_vendored.ibis.common.typing import evaluate_annotations -from typing_extensions import Self, dataclass_transform + +if sys.version_info >= (3, 11): + from typing import Self, dataclass_transform +else: + from typing_extensions import Self, dataclass_transform class AnnotableMeta(AbstractMeta): diff --git a/packages/bigframes/third_party/bigframes_vendored/ibis/common/typing.py b/packages/bigframes/third_party/bigframes_vendored/ibis/common/typing.py index c0c8ff3928c7..47590532cf6c 100644 --- a/packages/bigframes/third_party/bigframes_vendored/ibis/common/typing.py +++ b/packages/bigframes/third_party/bigframes_vendored/ibis/common/typing.py @@ -7,26 +7,23 @@ import sys from abc import abstractmethod from itertools import zip_longest -from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union, get_args, get_origin +from typing import TYPE_CHECKING, Any, Optional, TypeVar, get_args, get_origin from typing import get_type_hints as _get_type_hints from bigframes_vendored.ibis.common.bases import Abstract from bigframes_vendored.ibis.common.caching import memoize if TYPE_CHECKING: - from typing_extensions import Self - -if sys.version_info >= (3, 10): - from types import UnionType - from typing import TypeAlias + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self - # Keep this alias in sync with unittest.case._ClassInfo - _ClassInfo: TypeAlias = type | UnionType | tuple["_ClassInfo", ...] -else: - from typing_extensions import TypeAlias +from types import UnionType +from typing import TypeAlias - UnionType = object() - _ClassInfo: TypeAlias = Union[type, tuple["_ClassInfo", ...]] +# Keep this alias in sync with unittest.case._ClassInfo +_ClassInfo: TypeAlias = type | UnionType | tuple["_ClassInfo", ...] T = TypeVar("T") diff --git a/packages/bigframes/third_party/bigframes_vendored/ibis/expr/builders.py b/packages/bigframes/third_party/bigframes_vendored/ibis/expr/builders.py index c7b6e538ff54..850c56d8437b 100644 --- a/packages/bigframes/third_party/bigframes_vendored/ibis/expr/builders.py +++ b/packages/bigframes/third_party/bigframes_vendored/ibis/expr/builders.py @@ -3,6 +3,7 @@ from __future__ import annotations import math +import sys from typing import TYPE_CHECKING, Any, Literal, Optional, Union import bigframes_vendored.ibis @@ -19,7 +20,10 @@ from bigframes_vendored.ibis.common.typing import VarTuple # noqa: TCH001 if TYPE_CHECKING: - from typing_extensions import Self + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self class Builder(Concrete): diff --git a/packages/bigframes/third_party/bigframes_vendored/ibis/expr/datatypes/core.py b/packages/bigframes/third_party/bigframes_vendored/ibis/expr/datatypes/core.py index 75bff716626c..c40017e758bc 100644 --- a/packages/bigframes/third_party/bigframes_vendored/ibis/expr/datatypes/core.py +++ b/packages/bigframes/third_party/bigframes_vendored/ibis/expr/datatypes/core.py @@ -5,6 +5,7 @@ import datetime as pydatetime import decimal as pydecimal import numbers +import sys import uuid as pyuuid from abc import abstractmethod from collections.abc import Iterable, Iterator, Mapping, Sequence @@ -29,7 +30,11 @@ from bigframes_vendored.ibis.common.patterns import Coercible, CoercionError from bigframes_vendored.ibis.common.temporal import IntervalUnit, TimestampUnit from public import public -from typing_extensions import Self + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self @lazy_singledispatch diff --git a/packages/bigframes/third_party/bigframes_vendored/ibis/expr/operations/core.py b/packages/bigframes/third_party/bigframes_vendored/ibis/expr/operations/core.py index ad0bd095b6c7..2afe11efca64 100644 --- a/packages/bigframes/third_party/bigframes_vendored/ibis/expr/operations/core.py +++ b/packages/bigframes/third_party/bigframes_vendored/ibis/expr/operations/core.py @@ -2,8 +2,9 @@ from __future__ import annotations +import sys from abc import abstractmethod -from typing import Generic, Optional +from typing import Any, Generic, Optional import bigframes_vendored.ibis.expr.datashape as ds import bigframes_vendored.ibis.expr.datatypes as dt @@ -15,7 +16,12 @@ from bigframes_vendored.ibis.common.typing import DefaultTypeVars from bigframes_vendored.ibis.util import is_iterable from public import public -from typing_extensions import Any, Self, TypeVar +from typing_extensions import TypeVar + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self @public diff --git a/packages/bigframes/third_party/bigframes_vendored/pandas/pandas/_typing.py b/packages/bigframes/third_party/bigframes_vendored/pandas/pandas/_typing.py index 3640ba251630..6e45b48c4e15 100644 --- a/packages/bigframes/third_party/bigframes_vendored/pandas/pandas/_typing.py +++ b/packages/bigframes/third_party/bigframes_vendored/pandas/pandas/_typing.py @@ -65,10 +65,7 @@ # Name "npt._ArrayLikeInt_co" is not defined [name-defined] NumpySorter = Optional[npt._ArrayLikeInt_co] # type: ignore[name-defined] - if sys.version_info >= (3, 10): - from typing import TypeGuard - else: - from typing_extensions import TypeGuard # pyright: reportUnusedImport = false + from typing import TypeGuard if sys.version_info >= (3, 11): from typing import Self diff --git a/packages/bigframes/third_party/bigframes_vendored/sqlglot/expressions.py b/packages/bigframes/third_party/bigframes_vendored/sqlglot/expressions.py index e8e4cc8e10d6..0a868c7c5061 100644 --- a/packages/bigframes/third_party/bigframes_vendored/sqlglot/expressions.py +++ b/packages/bigframes/third_party/bigframes_vendored/sqlglot/expressions.py @@ -43,7 +43,11 @@ if t.TYPE_CHECKING: from bigframes_vendored.sqlglot._typing import E, Lit from bigframes_vendored.sqlglot.dialects.dialect import DialectType - from typing_extensions import Self + + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self Q = t.TypeVar("Q", bound="Query") S = t.TypeVar("S", bound="SetOperation") diff --git a/packages/gapic-generator/gapic/configurable_snippetgen/snippet_config_language_pb2.pyi b/packages/gapic-generator/gapic/configurable_snippetgen/snippet_config_language_pb2.pyi index fb61af2905cf..92802d63901e 100644 --- a/packages/gapic-generator/gapic/configurable_snippetgen/snippet_config_language_pb2.pyi +++ b/packages/gapic-generator/gapic/configurable_snippetgen/snippet_config_language_pb2.pyi @@ -24,10 +24,7 @@ import google.protobuf.message import sys import typing -if sys.version_info >= (3, 10): - import typing as typing_extensions -else: - import typing_extensions +import typing as typing_extensions DESCRIPTOR: google.protobuf.descriptor.FileDescriptor diff --git a/packages/google-api-core/google/api_core/retry/retry_streaming.py b/packages/google-api-core/google/api_core/retry/retry_streaming.py index e4474c8afdcf..17cb27c16929 100644 --- a/packages/google-api-core/google/api_core/retry/retry_streaming.py +++ b/packages/google-api-core/google/api_core/retry/retry_streaming.py @@ -29,7 +29,6 @@ TYPE_CHECKING, ) -import sys import time import functools @@ -40,10 +39,7 @@ from google.api_core.retry import RetryFailureReason if TYPE_CHECKING: - if sys.version_info >= (3, 10): - from typing import ParamSpec - else: - from typing_extensions import ParamSpec + from typing import ParamSpec _P = ParamSpec("_P") # target function call parameters _Y = TypeVar("_Y") # yielded values diff --git a/packages/google-api-core/google/api_core/retry/retry_streaming_async.py b/packages/google-api-core/google/api_core/retry/retry_streaming_async.py index 5e5fa2402478..250738116031 100644 --- a/packages/google-api-core/google/api_core/retry/retry_streaming_async.py +++ b/packages/google-api-core/google/api_core/retry/retry_streaming_async.py @@ -43,10 +43,7 @@ if TYPE_CHECKING: - if sys.version_info >= (3, 10): - from typing import ParamSpec - else: - from typing_extensions import ParamSpec + from typing import ParamSpec _P = ParamSpec("_P") # target function call parameters _Y = TypeVar("_Y") # yielded values diff --git a/packages/google-api-core/google/api_core/retry/retry_unary.py b/packages/google-api-core/google/api_core/retry/retry_unary.py index 6d36bc7d1a45..13db5dafd63d 100644 --- a/packages/google-api-core/google/api_core/retry/retry_unary.py +++ b/packages/google-api-core/google/api_core/retry/retry_unary.py @@ -57,7 +57,6 @@ def check_if_exists(): from __future__ import annotations import functools -import sys import time import inspect import warnings @@ -71,10 +70,7 @@ def check_if_exists(): if TYPE_CHECKING: - if sys.version_info >= (3, 10): - from typing import ParamSpec - else: - from typing_extensions import ParamSpec + from typing import ParamSpec _P = ParamSpec("_P") # target function call parameters _R = TypeVar("_R") # target function returned value diff --git a/packages/google-api-core/google/api_core/retry/retry_unary_async.py b/packages/google-api-core/google/api_core/retry/retry_unary_async.py index 1f72476aff13..3b5133d8ad3f 100644 --- a/packages/google-api-core/google/api_core/retry/retry_unary_async.py +++ b/packages/google-api-core/google/api_core/retry/retry_unary_async.py @@ -76,12 +76,7 @@ async def check_if_exists(): from google.api_core.retry.retry_base import if_transient_error # noqa if TYPE_CHECKING: - import sys - - if sys.version_info >= (3, 10): - from typing import ParamSpec - else: - from typing_extensions import ParamSpec + from typing import ParamSpec _P = ParamSpec("_P") # target function call parameters _R = TypeVar("_R") # target function returned value diff --git a/packages/google-cloud-bigtable/google/cloud/bigtable/data/_cross_sync/cross_sync.py b/packages/google-cloud-bigtable/google/cloud/bigtable/data/_cross_sync/cross_sync.py index ae9aeda83560..ee302274c30f 100644 --- a/packages/google-cloud-bigtable/google/cloud/bigtable/data/_cross_sync/cross_sync.py +++ b/packages/google-cloud-bigtable/google/cloud/bigtable/data/_cross_sync/cross_sync.py @@ -69,7 +69,7 @@ async def async_func(self, arg: int) -> int: from ._mapping_meta import MappingMeta if TYPE_CHECKING: - from typing_extensions import TypeAlias + from typing import TypeAlias T = TypeVar("T") diff --git a/packages/google-cloud-spanner/google/cloud/aio/_cross_sync/cross_sync.py b/packages/google-cloud-spanner/google/cloud/aio/_cross_sync/cross_sync.py index 28305e2b6b16..630838190793 100644 --- a/packages/google-cloud-spanner/google/cloud/aio/_cross_sync/cross_sync.py +++ b/packages/google-cloud-spanner/google/cloud/aio/_cross_sync/cross_sync.py @@ -64,7 +64,7 @@ async def async_func(self, arg: int) -> int: from ._mapping_meta import MappingMeta if TYPE_CHECKING: - from typing_extensions import TypeAlias + from typing import TypeAlias T = TypeVar("T")