core: Add ruff rules RET (#29384)

See https://docs.astral.sh/ruff/rules/#flake8-return-ret
All auto-fixes
This commit is contained in:
Christophe Bornet
2025-04-02 22:59:56 +02:00
committed by GitHub
parent 9ae792f56c
commit f241fd5c11
70 changed files with 626 additions and 813 deletions

View File

@@ -60,11 +60,9 @@ class ChatGeneration(Generation):
if isinstance(block, str):
text = block
break
elif isinstance(block, dict) and "text" in block:
if isinstance(block, dict) and "text" in block:
text = block["text"]
break
else:
pass
else:
pass
self.text = text
@@ -104,7 +102,7 @@ class ChatGenerationChunk(ChatGeneration):
message=self.message + other.message,
generation_info=generation_info or None,
)
elif isinstance(other, list) and all(
if isinstance(other, list) and all(
isinstance(x, ChatGenerationChunk) for x in other
):
generation_info = merge_dicts(
@@ -115,8 +113,5 @@ class ChatGenerationChunk(ChatGeneration):
message=self.message + [chunk.message for chunk in other],
generation_info=generation_info or None,
)
else:
msg = (
f"unsupported operand type(s) for +: '{type(self)}' and '{type(other)}'"
)
raise TypeError(msg)
msg = f"unsupported operand type(s) for +: '{type(self)}' and '{type(other)}'"
raise TypeError(msg)

View File

@@ -64,8 +64,5 @@ class GenerationChunk(Generation):
text=self.text + other.text,
generation_info=generation_info or None,
)
else:
msg = (
f"unsupported operand type(s) for +: '{type(self)}' and '{type(other)}'"
)
raise TypeError(msg)
msg = f"unsupported operand type(s) for +: '{type(self)}' and '{type(other)}'"
raise TypeError(msg)