From a13c2dcca2cb3eb99b9c886c75dee3a1556ca8f5 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Mon, 18 Nov 2024 21:22:45 -0500 Subject: [PATCH] Refactor typing annotations in ChatManager and ChatAPI to use Union for older python. --- lib/galaxy/managers/chat.py | 7 +++++-- lib/galaxy/webapps/galaxy/api/chat.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/managers/chat.py b/lib/galaxy/managers/chat.py index f3447e9aca72..366152460ee1 100644 --- a/lib/galaxy/managers/chat.py +++ b/lib/galaxy/managers/chat.py @@ -1,4 +1,7 @@ -from typing import Optional +from typing import ( + Optional, + Union, +) from fastapi import Path from sqlalchemy import ( @@ -59,7 +62,7 @@ def create(self, trans: ProvidesUserContext, job_id: JobIdPathParam, message: st trans.sa_session.commit() return chat_exchange - def get(self, trans: ProvidesUserContext, job_id: JobIdPathParam) -> ChatExchange | None: + def get(self, trans: ProvidesUserContext, job_id: JobIdPathParam) -> Union[ChatExchange, None]: """ Returns the chat response from the DB based on the given job id. :param job_id: id of the job to load a response for from the DB diff --git a/lib/galaxy/webapps/galaxy/api/chat.py b/lib/galaxy/webapps/galaxy/api/chat.py index 5723fbf4815c..7a48cc4fae36 100644 --- a/lib/galaxy/webapps/galaxy/api/chat.py +++ b/lib/galaxy/webapps/galaxy/api/chat.py @@ -3,6 +3,7 @@ """ import logging +from typing import Union from galaxy.config import GalaxyAppConfiguration from galaxy.exceptions import ConfigurationError @@ -75,7 +76,7 @@ def feedback( job_id: JobIdPathParam, feedback: int, trans: ProvidesUserContext = DependsOnTrans, - ) -> int | None: + ) -> Union[int, None]: """Provide feedback on the chatbot response.""" job = self.job_manager.get_accessible_job(trans, job_id) chat_response = self.chat_manager.set_feedback_for_job(trans, job.id, feedback)