mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-23 11:30:37 +00:00
core: Improve mypy config (#30737)
* Cleanup mypy config * Add mypy `strict` rules except `disallow_any_generics`, `warn_return_any` and `strict_equality` (TODO) * Add mypy `strict_byte` rule * Add mypy support for PEP702 `@deprecated` decorator * Bump mypy version to 1.15 --------- Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
committed by
GitHub
parent
bb2c2fd885
commit
42944f3499
@@ -129,7 +129,7 @@ class BaseMessagePromptTemplate(Serializable, ABC):
|
||||
Returns:
|
||||
Combined prompt template.
|
||||
"""
|
||||
prompt = ChatPromptTemplate(messages=[self]) # type: ignore[call-arg]
|
||||
prompt = ChatPromptTemplate(messages=[self])
|
||||
return prompt + other
|
||||
|
||||
|
||||
@@ -1033,23 +1033,23 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
|
||||
if isinstance(other, ChatPromptTemplate):
|
||||
return ChatPromptTemplate(messages=self.messages + other.messages).partial(
|
||||
**partials
|
||||
) # type: ignore[call-arg]
|
||||
)
|
||||
if isinstance(
|
||||
other, (BaseMessagePromptTemplate, BaseMessage, BaseChatPromptTemplate)
|
||||
):
|
||||
return ChatPromptTemplate(messages=self.messages + [other]).partial(
|
||||
**partials
|
||||
) # type: ignore[call-arg]
|
||||
)
|
||||
if isinstance(other, (list, tuple)):
|
||||
_other = ChatPromptTemplate.from_messages(other)
|
||||
return ChatPromptTemplate(messages=self.messages + _other.messages).partial(
|
||||
**partials
|
||||
) # type: ignore[call-arg]
|
||||
)
|
||||
if isinstance(other, str):
|
||||
prompt = HumanMessagePromptTemplate.from_template(other)
|
||||
return ChatPromptTemplate(messages=self.messages + [prompt]).partial(
|
||||
**partials
|
||||
) # type: ignore[call-arg]
|
||||
)
|
||||
msg = f"Unsupported operand type for +: {type(other)}"
|
||||
raise NotImplementedError(msg)
|
||||
|
||||
@@ -1138,7 +1138,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
|
||||
Returns:
|
||||
a chat prompt template.
|
||||
"""
|
||||
return cls( # type: ignore[call-arg]
|
||||
return cls(
|
||||
messages=[
|
||||
ChatMessagePromptTemplate.from_template(template, role=role)
|
||||
for role, template in string_messages
|
||||
|
@@ -116,7 +116,7 @@ class ImagePromptTemplate(BasePromptTemplate[ImageURL]):
|
||||
output: ImageURL = {"url": url}
|
||||
if detail:
|
||||
# Don't check literal values here: let the API check them
|
||||
output["detail"] = detail # type: ignore[typeddict-item]
|
||||
output["detail"] = detail
|
||||
return output
|
||||
|
||||
async def aformat(self, **kwargs: Any) -> ImageURL:
|
||||
|
@@ -297,7 +297,7 @@ class PromptTemplate(StringPromptTemplate):
|
||||
return cls(
|
||||
input_variables=input_variables,
|
||||
template=template,
|
||||
template_format=template_format, # type: ignore[arg-type]
|
||||
template_format=template_format,
|
||||
partial_variables=_partial_variables,
|
||||
**kwargs,
|
||||
)
|
||||
|
Reference in New Issue
Block a user