fix: import deprecated from typing_extensions

Fixes https://github.com/google/adk-python/issues/1125

and add it to pyproject.toml. This was added to typing_extensions in 4.5.0. I followed versioning guidance from https://typing-extensions.readthedocs.io/en/latest/index.html#versioning-and-backwards-compatibility.

PiperOrigin-RevId: 767317467
This commit is contained in:
Google Team Member
2025-06-04 15:51:43 -07:00
committed by Copybara-Service
parent 86e15cab89
commit 068df04bce
4 changed files with 19 additions and 13 deletions
+1
View File
@@ -44,6 +44,7 @@ dependencies = [
"PyYAML>=6.0.2", # For APIHubToolset. "PyYAML>=6.0.2", # For APIHubToolset.
"sqlalchemy>=2.0", # SQL database ORM "sqlalchemy>=2.0", # SQL database ORM
"tzlocal>=5.3", # Time zone utilities "tzlocal>=5.3", # Time zone utilities
"typing-extensions>=4.5, <5",
"uvicorn>=0.34.0", # ASGI server for FastAPI "uvicorn>=0.34.0", # ASGI server for FastAPI
# go/keep-sorted end # go/keep-sorted end
] ]
+4 -2
View File
@@ -12,18 +12,20 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import annotations
from typing import Any from typing import Any
from typing import Tuple from typing import Tuple
from deprecated import deprecated
from google.genai import types as genai_types from google.genai import types as genai_types
from typing_extensions import deprecated
from ...evaluation.eval_case import IntermediateData from ...evaluation.eval_case import IntermediateData
from ...evaluation.eval_case import Invocation from ...evaluation.eval_case import Invocation
from ...sessions.session import Session from ...sessions.session import Session
@deprecated(reason='Use convert_session_to_eval_invocations instead.') @deprecated('Use convert_session_to_eval_invocations instead.')
def convert_session_to_eval_format(session: Session) -> list[dict[str, Any]]: def convert_session_to_eval_format(session: Session) -> list[dict[str, Any]]:
"""Converts a session data into eval format. """Converts a session data into eval format.
@@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import annotations
from typing import Any from typing import Any
from typing import Optional from typing import Optional
from deprecated import deprecated
from google.genai import types as genai_types from google.genai import types as genai_types
import pandas as pd import pandas as pd
from tabulate import tabulate from tabulate import tabulate
from typing_extensions import deprecated
from typing_extensions import override from typing_extensions import override
from vertexai.preview.evaluation import EvalTask from vertexai.preview.evaluation import EvalTask
from vertexai.preview.evaluation import MetricPromptTemplateExamples from vertexai.preview.evaluation import MetricPromptTemplateExamples
@@ -124,10 +126,8 @@ class ResponseEvaluator(Evaluator):
@staticmethod @staticmethod
@deprecated( @deprecated(
reason=( "This method has been deprecated and will be removed soon. Please use"
"This method has been deprecated and will be removed soon. Please use" " evaluate_invocations instead."
" evaluate_invocations instead."
)
) )
def evaluate( def evaluate(
raw_eval_dataset: list[list[dict[str, Any]]], raw_eval_dataset: list[list[dict[str, Any]]],
@@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import annotations
from typing import Any from typing import Any
from typing import cast from typing import cast
from deprecated import deprecated
from google.genai import types as genai_types from google.genai import types as genai_types
import pandas as pd import pandas as pd
from tabulate import tabulate from tabulate import tabulate
from typing_extensions import deprecated
from typing_extensions import override from typing_extensions import override
from .eval_case import Invocation from .eval_case import Invocation
@@ -100,10 +102,8 @@ class TrajectoryEvaluator(Evaluator):
@staticmethod @staticmethod
@deprecated( @deprecated(
reason=( "This method has been deprecated and will be removed soon. Please use"
"This method has been deprecated and will be removed soon. Please use" " evaluate_invocations instead."
" evaluate_invocations instead."
)
) )
def evaluate( def evaluate(
eval_dataset: list[list[dict[str, Any]]], eval_dataset: list[list[dict[str, Any]]],
@@ -218,7 +218,10 @@ class TrajectoryEvaluator(Evaluator):
return new_row, failure return new_row, failure
@staticmethod @staticmethod
@deprecated() @deprecated(
"are_tools_equal is deprecated and will be removed soon. Please use"
" TrajectoryEvaluator._are_tool_calls_equal instead."
)
def are_tools_equal(list_a_original, list_b_original): def are_tools_equal(list_a_original, list_b_original):
# Remove other entries that we don't want to evaluate # Remove other entries that we don't want to evaluate
list_a = [ list_a = [