Apply lint

This commit is contained in:
Sadra Barikbin 2025-07-27 02:02:00 +03:30
parent 84f8b99cf5
commit 4b74e35532
2 changed files with 7 additions and 4 deletions

View File

@ -138,8 +138,8 @@ class PromptTemplate(StringPromptTemplate):
# Allow for easy combining
if isinstance(other, PromptTemplate):
if self.template_format != other.template_format:
msg = "Cannot add two templates of different formats"
raise ValueError(msg)
msg = "Cannot add templates of different formats"
raise ValueError(msg)
input_variables = list(
set(self.input_variables) | set(other.input_variables)
)
@ -160,7 +160,10 @@ class PromptTemplate(StringPromptTemplate):
validate_template=validate_template,
)
if isinstance(other, str):
prompt = PromptTemplate.from_template(other, template_format=self.template_format)
prompt = PromptTemplate.from_template(
other,
template_format=self.template_format,
)
return self + prompt
msg = f"Unsupported operand type for +: {type(other)}"
raise NotImplementedError(msg)

View File

@ -684,7 +684,7 @@ def test_prompt_with_template_variable_name_jinja2() -> None:
def test_prompt_template_add_with_with_another_format():
with pytest.raises(match=r"Cannot add two templates"):
with pytest.raises(match=r"Cannot add templates"):
PromptTemplate.from_template("This is a {template}") + PromptTemplate.from_template("So {{this}} is", template_format="mustache")