From dfcaeba1665b9ba831a726584b7f64ac72962c65 Mon Sep 17 00:00:00 2001 From: Sergii Tkachenko Date: Tue, 8 Oct 2024 13:59:46 -0700 Subject: [PATCH] minor: Use native TypeAlias --- framework/helpers/grpc.py | 3 +-- framework/infrastructure/k8s.py | 4 ++-- framework/infrastructure/traffic_director.py | 3 +-- framework/rpc/grpc_csds.py | 3 +-- framework/rpc/grpc_testing.py | 3 +-- framework/test_cases/session_affinity_mixin.py | 4 +--- tests/app_net_ssa_test.py | 3 +-- tests/dualstack_test.py | 2 +- tests/gamma/affinity_session_drain_test.py | 4 ++-- tests/gamma/affinity_test.py | 4 ++-- 10 files changed, 13 insertions(+), 20 deletions(-) diff --git a/framework/helpers/grpc.py b/framework/helpers/grpc.py index 43c76a6a..f1441607 100644 --- a/framework/helpers/grpc.py +++ b/framework/helpers/grpc.py @@ -15,10 +15,9 @@ import collections import dataclasses import functools -from typing import Optional +from typing import Optional, TypeAlias import grpc -from typing_extensions import TypeAlias import yaml from framework.rpc import grpc_testing diff --git a/framework/infrastructure/k8s.py b/framework/infrastructure/k8s.py index 8562f16e..d9dbbe27 100644 --- a/framework/infrastructure/k8s.py +++ b/framework/infrastructure/k8s.py @@ -21,7 +21,7 @@ import logging import pathlib import threading -from typing import Any, Callable, Final, List, Optional, Tuple, Union +from typing import Any, Callable, Final, List, Optional, Tuple, TypeAlias, Union import warnings from kubernetes import client @@ -30,7 +30,7 @@ import kubernetes.config from kubernetes.dynamic import exceptions as dynamic_exc from kubernetes.dynamic import resource as dynamic_res -from typing_extensions import Self, TypeAlias, override +from typing_extensions import Self, override import urllib3.exceptions import yaml diff --git a/framework/infrastructure/traffic_director.py b/framework/infrastructure/traffic_director.py index 0004ad9d..3d048acc 100644 --- a/framework/infrastructure/traffic_director.py +++ b/framework/infrastructure/traffic_director.py @@ -14,10 +14,9 @@ import functools import logging import random -from typing import Any, Dict, Final, List, Optional +from typing import Any, Dict, Final, List, Optional, TypeAlias import googleapiclient.errors -from typing_extensions import TypeAlias from framework import xds_flags from framework.infrastructure import gcp diff --git a/framework/rpc/grpc_csds.py b/framework/rpc/grpc_csds.py index df2460c9..545fe9f3 100644 --- a/framework/rpc/grpc_csds.py +++ b/framework/rpc/grpc_csds.py @@ -19,10 +19,9 @@ import json import logging import re -from typing import Any, Final, Optional, Type, cast +from typing import Any, Final, Optional, Type, TypeAlias, cast from google.protobuf import json_format -from typing_extensions import TypeAlias # Needed to load the descriptors so that Any is parsed # TODO(sergiitk): replace with import xds_protos when it works diff --git a/framework/rpc/grpc_testing.py b/framework/rpc/grpc_testing.py index 80d19da6..d764518f 100644 --- a/framework/rpc/grpc_testing.py +++ b/framework/rpc/grpc_testing.py @@ -18,13 +18,12 @@ from collections.abc import Sequence import datetime as dt import logging -from typing import Any, Final, Optional, cast +from typing import Any, Final, Optional, TypeAlias, cast from google.protobuf import json_format import grpc from grpc_health.v1 import health_pb2 from grpc_health.v1 import health_pb2_grpc -from typing_extensions import TypeAlias import framework.rpc from protos.grpc.testing import empty_pb2 diff --git a/framework/test_cases/session_affinity_mixin.py b/framework/test_cases/session_affinity_mixin.py index d34ff54e..9dff7825 100644 --- a/framework/test_cases/session_affinity_mixin.py +++ b/framework/test_cases/session_affinity_mixin.py @@ -20,9 +20,7 @@ """ import datetime as dt import logging -from typing import Final, Sequence, Union - -from typing_extensions import TypeAlias +from typing import Final, Sequence, TypeAlias, Union from framework import xds_k8s_testcase from framework.helpers import retryers diff --git a/tests/app_net_ssa_test.py b/tests/app_net_ssa_test.py index 3e1a2f8b..42076f70 100644 --- a/tests/app_net_ssa_test.py +++ b/tests/app_net_ssa_test.py @@ -12,11 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging -from typing import Final, List, Optional +from typing import Final, List, Optional, TypeAlias from absl import flags from absl.testing import absltest -from typing_extensions import TypeAlias from framework import xds_k8s_testcase from framework.helpers import skips diff --git a/tests/dualstack_test.py b/tests/dualstack_test.py index 8b72099c..20bd1753 100644 --- a/tests/dualstack_test.py +++ b/tests/dualstack_test.py @@ -17,7 +17,7 @@ from absl import flags from absl.testing import absltest -from typing_extensions import TypeAlias, override +from typing_extensions import override from framework import xds_k8s_flags from framework import xds_k8s_testcase diff --git a/tests/gamma/affinity_session_drain_test.py b/tests/gamma/affinity_session_drain_test.py index da0eb8f8..e7b2e1b0 100644 --- a/tests/gamma/affinity_session_drain_test.py +++ b/tests/gamma/affinity_session_drain_test.py @@ -13,11 +13,11 @@ # limitations under the License. import datetime as dt import logging -from typing import Final, Optional +from typing import Final, Optional, TypeAlias from absl import flags from absl.testing import absltest -from typing_extensions import TypeAlias, override +from typing_extensions import override from framework import xds_gamma_testcase from framework import xds_k8s_testcase diff --git a/tests/gamma/affinity_test.py b/tests/gamma/affinity_test.py index 16b44ee3..bdae43cd 100644 --- a/tests/gamma/affinity_test.py +++ b/tests/gamma/affinity_test.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging -from typing import List, Optional +from typing import List, Optional, TypeAlias from absl import flags from absl.testing import absltest -from typing_extensions import TypeAlias, override +from typing_extensions import override from framework import xds_gamma_testcase from framework import xds_k8s_testcase