mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-23 11:30:37 +00:00
core: Add ruff rules FBT001 and FBT002 (#30695)
Add ruff rules [FBT001](https://docs.astral.sh/ruff/rules/boolean-type-hint-positional-argument/) and [FBT002](https://docs.astral.sh/ruff/rules/boolean-default-value-positional-argument/). Mostly `noqa`s to not introduce breaking changes and possible non-breaking fixes have already been done in a [previous PR](https://github.com/langchain-ai/langchain/pull/29424). These rules will prevent new violations to happen.
This commit is contained in:
committed by
GitHub
parent
2803a48661
commit
913c896598
@@ -102,7 +102,10 @@ class BaseMessagePromptTemplate(Serializable, ABC):
|
||||
List of input variables.
|
||||
"""
|
||||
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
def pretty_repr(
|
||||
self,
|
||||
html: bool = False, # noqa: FBT001,FBT002
|
||||
) -> str:
|
||||
"""Human-readable representation.
|
||||
|
||||
Args:
|
||||
@@ -270,6 +273,7 @@ class MessagesPlaceholder(BaseMessagePromptTemplate):
|
||||
"""
|
||||
return [self.variable_name] if not self.optional else []
|
||||
|
||||
@override
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
"""Human-readable representation.
|
||||
|
||||
@@ -406,6 +410,7 @@ class BaseStringMessagePromptTemplate(BaseMessagePromptTemplate, ABC):
|
||||
"""
|
||||
return self.prompt.input_variables
|
||||
|
||||
@override
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
"""Human-readable representation.
|
||||
|
||||
@@ -675,6 +680,7 @@ class _StringImageMessagePromptTemplate(BaseMessagePromptTemplate):
|
||||
content=content, additional_kwargs=self.additional_kwargs
|
||||
)
|
||||
|
||||
@override
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
"""Human-readable representation.
|
||||
|
||||
@@ -777,7 +783,10 @@ class BaseChatPromptTemplate(BasePromptTemplate, ABC):
|
||||
"""Async format kwargs into a list of messages."""
|
||||
return self.format_messages(**kwargs)
|
||||
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
def pretty_repr(
|
||||
self,
|
||||
html: bool = False, # noqa: FBT001,FBT002
|
||||
) -> str:
|
||||
"""Human-readable representation.
|
||||
|
||||
Args:
|
||||
@@ -1331,6 +1340,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@override
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
"""Human-readable representation.
|
||||
|
||||
|
@@ -10,6 +10,7 @@ from pydantic import (
|
||||
Field,
|
||||
model_validator,
|
||||
)
|
||||
from typing_extensions import override
|
||||
|
||||
from langchain_core.example_selectors import BaseExampleSelector
|
||||
from langchain_core.messages import BaseMessage, get_buffer_string
|
||||
@@ -453,6 +454,7 @@ class FewShotChatMessagePromptTemplate(
|
||||
messages = await self.aformat_messages(**kwargs)
|
||||
return get_buffer_string(messages)
|
||||
|
||||
@override
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
"""Return a pretty representation of the prompt template.
|
||||
|
||||
|
@@ -133,7 +133,10 @@ class ImagePromptTemplate(BasePromptTemplate[ImageURL]):
|
||||
"""
|
||||
return await run_in_executor(None, self.format, **kwargs)
|
||||
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
def pretty_repr(
|
||||
self,
|
||||
html: bool = False, # noqa: FBT001,FBT002
|
||||
) -> str:
|
||||
"""Return a pretty representation of the prompt.
|
||||
|
||||
Args:
|
||||
|
@@ -293,7 +293,10 @@ class StringPromptTemplate(BasePromptTemplate, ABC):
|
||||
"""
|
||||
return StringPromptValue(text=await self.aformat(**kwargs))
|
||||
|
||||
def pretty_repr(self, html: bool = False) -> str:
|
||||
def pretty_repr(
|
||||
self,
|
||||
html: bool = False, # noqa: FBT001,FBT002
|
||||
) -> str:
|
||||
"""Get a pretty representation of the prompt.
|
||||
|
||||
Args:
|
||||
|
Reference in New Issue
Block a user