Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/user_prompt_support/prompt_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ def __init__(
super().__init__(**kwargs)
# Preserve the original response
if "response" in kwargs:
self.response_str = kwargs["response"]
self.response_str = (
str(kwargs["response"]) if kwargs["response"] is not None else None
)
Comment on lines +38 to +40

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the current implementation is correct, it can be made more concise and avoid repetition by using an assignment expression (walrus operator, :=). This assigns the value of kwargs['response'] to a variable and checks if it's not None in the same expression, improving readability and maintainability.

            self.response_str = str(v) if (v := kwargs["response"]) is not None else None

Loading