Skip to content

Commit

Permalink
Refactor typing annotations in ChatManager and ChatAPI to use Union f…
Browse files Browse the repository at this point in the history
…or older python.
  • Loading branch information
dannon committed Nov 19, 2024
1 parent 8aadf1a commit a13c2dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/galaxy/managers/chat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import Optional
from typing import (
Optional,
Union,
)

from fastapi import Path
from sqlalchemy import (
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/api/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging
from typing import Union

from galaxy.config import GalaxyAppConfiguration
from galaxy.exceptions import ConfigurationError
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a13c2dc

Please sign in to comment.