Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

`TypeError: Plain typing.TypeAlias is not valid as type argument` in vertexai/_genai/_agent_engines_utils.py on Python 3.10

Abierto
#6,404 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 6 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
google-cloud, python

Línea de trabajo

Comienza en vertexai/_genai/_agent_engines_utils.py en la línea 289 y revisa la ruta de anotación de ADKAgent en tiempo de ejecución. Reproduce la importación en Python 3.10 con las versiones afectadas de las dependencias y, a continuación, verifica que importar el módulo ya no provoque un TypeError, mientras el comportamiento de la importación opcional de google.adk se mantiene intacto.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

api: vertex-ai
Environment details
  • Python: 3.10.1
  • google-cloud-aiplatform: 1.140.0
  • google-adk: 1.26.0
  • OS: Linux (Kubernetes)
  • Buggy versions: 1.136.0, 1.137.0, 1.138.0, 1.139.0, 1.140.0
  • Python versions affected: 3.10.x
  • Last working version: 1.135.0
Steps to reproduce

Not sure this was encountered while using google adk which has this as a dependency.
Full traceback of error after making a POST request to create a session which triggered this error:

Traceback (most recent call last):
  File "/root/.pyenv/versions/3.10/lib/python3.10/site-packages/google/adk/cli/adk_web_server.py", line 660, in _create_session
    session = await self.session_service.create_session(
  File "/root/.pyenv/versions/3.10/lib/python3.10/site-packages/google/adk/sessions/vertex_ai_session_service.py", line 115, in create_session
    api_response = await api_client.agent_engines.sessions.create(
  File "/root/.pyenv/versions/3.10/lib/python3.10/site-packages/vertexai/_genai/client.py", line 111, in agent_engines
    self._agent_engines = importlib.import_module(
  File "/root/.pyenv/versions/3.10.1/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/root/.pyenv/versions/3.10/lib/python3.10/site-packages/vertexai/_genai/agent_engines.py", line 34, in <module>
    from . import _agent_engines_utils
  File "/root/.pyenv/versions/3.10/lib/python3.10/site-packages/vertexai/_genai/_agent_engines_utils.py", line 289, in <module>
    ADKAgent: Optional[TypeAlias] = BaseAgent
  File "/root/.pyenv/versions/3.10.1/lib/python3.10/typing.py", line 311, in inner
    return func(*args, **kwds)
  File "/root/.pyenv/versions/3.10.1/lib/python3.10/typing.py", line 402, in __getitem__
    return self._getitem(self, parameters)
  File "/root/.pyenv/versions/3.10.1/lib/python3.10/typing.py", line 528, in Optional
    arg = _type_check(parameters, f"{self} requires a single type.")
  File "/root/.pyenv/versions/3.10.1/lib/python3.10/typing.py", line 171, in _type_check
    raise TypeError(f"Plain {arg} is not valid as type argument")
TypeError: Plain typing.TypeAlias is not valid as type argument
Root Cause

File: vertexai/_genai/_agent_engines_utils.py
Line: 289

if typing.TYPE_CHECKING:
    from google.adk.agents import BaseAgent

    ADKAgent: TypeAlias = BaseAgent
else:
    try:
        from google.adk.agents import BaseAgent

        ADKAgent: Optional[TypeAlias] = BaseAgent  # this is the line causing issues
    except (ImportError, AttributeError):
        ADKAgent = None  # type: ignore[no-redef]

Not sure the syntax Optional[TypeAlias] valid 3.10? Confusing though since I think the syntax is valid unclear why it would cause this runtime error.

Introduced in: https://github.com/googleapis/python-aiplatform/commit/d8cc50dd67

Workaround

Pin to version 1.135.0 or earlier:

google-cloud-aiplatform = "1.135.0"
Lenguaje dominante
Python
Estrellas
907
Forks
467
Merge medio
1 d 11 h
PR fusionados (30 d)
38

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de googleapis/python-aiplatform

Todos los issues de googleapis/python-aiplatform

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.