nathadfield commented on code in PR #39248:
URL: https://github.com/apache/airflow/pull/39248#discussion_r1580858126
##########
airflow/providers/openai/hooks/openai.py:
##########
@@ -133,26 +143,26 @@ def get_assistants(self, **kwargs: Any) ->
list[Assistant]:
return assistants.data
def get_assistant_by_name(self, assistant_name: str) -> Assistant | None:
- """Get an OpenAI Assistant object for a given name.
+ """
+ Get an OpenAI Assistant object for a given name.
:param assistant_name: The name of the assistant to retrieve
"""
- response = self.get_assistants()
- for assistant in response:
- if assistant.name == assistant_name:
- return assistant
- return None
+ assistants = self.get_assistants()
+ return next((assistant for assistant in assistants if assistant.name
== assistant_name), None)
Review Comment:
Yes, you can, which is perhaps not unsurprising. In that case, I think I
will remove the `get_x_by_name` functions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]