mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-08 06:23:20 +00:00
core: Bump ruff version to 0.12 (#31846)
This commit is contained in:
committed by
GitHub
parent
73552883c3
commit
8aed3b61a9
@@ -329,6 +329,7 @@ class StreamingModel(NoStreamingModel):
|
||||
|
||||
@pytest.mark.parametrize("disable_streaming", [True, False, "tool_calling"])
|
||||
def test_disable_streaming(
|
||||
*,
|
||||
disable_streaming: Union[bool, Literal["tool_calling"]],
|
||||
) -> None:
|
||||
model = StreamingModel(disable_streaming=disable_streaming)
|
||||
@@ -353,6 +354,7 @@ def test_disable_streaming(
|
||||
|
||||
@pytest.mark.parametrize("disable_streaming", [True, False, "tool_calling"])
|
||||
async def test_disable_streaming_async(
|
||||
*,
|
||||
disable_streaming: Union[bool, Literal["tool_calling"]],
|
||||
) -> None:
|
||||
model = StreamingModel(disable_streaming=disable_streaming)
|
||||
@@ -379,6 +381,7 @@ async def test_disable_streaming_async(
|
||||
|
||||
@pytest.mark.parametrize("disable_streaming", [True, False, "tool_calling"])
|
||||
def test_disable_streaming_no_streaming_model(
|
||||
*,
|
||||
disable_streaming: Union[bool, Literal["tool_calling"]],
|
||||
) -> None:
|
||||
model = NoStreamingModel(disable_streaming=disable_streaming)
|
||||
@@ -393,6 +396,7 @@ def test_disable_streaming_no_streaming_model(
|
||||
|
||||
@pytest.mark.parametrize("disable_streaming", [True, False, "tool_calling"])
|
||||
async def test_disable_streaming_no_streaming_model_async(
|
||||
*,
|
||||
disable_streaming: Union[bool, Literal["tool_calling"]],
|
||||
) -> None:
|
||||
model = NoStreamingModel(disable_streaming=disable_streaming)
|
||||
|
@@ -21,6 +21,8 @@ class NonBoolObj:
|
||||
def __repr__(self) -> str:
|
||||
return self.__class__.__name__
|
||||
|
||||
__hash__ = None # type: ignore[assignment]
|
||||
|
||||
|
||||
def test_simple_serialization() -> None:
|
||||
class Foo(Serializable):
|
||||
@@ -100,6 +102,8 @@ def test__is_field_useful() -> None:
|
||||
def __eq__(self, other: object) -> bool:
|
||||
return self # type: ignore[return-value]
|
||||
|
||||
__hash__ = None # type: ignore[assignment]
|
||||
|
||||
default_x = ArrayObj()
|
||||
default_y = NonBoolObj()
|
||||
|
||||
|
@@ -266,7 +266,7 @@ def test_prompt_jinja2_missing_input_variables(
|
||||
suffix = "Ending with {{ bar }}"
|
||||
|
||||
# Test when missing in suffix
|
||||
with pytest.warns(UserWarning):
|
||||
with pytest.warns(UserWarning, match="Missing variables: {'bar'}"):
|
||||
FewShotPromptTemplate(
|
||||
input_variables=[],
|
||||
suffix=suffix,
|
||||
@@ -284,7 +284,7 @@ def test_prompt_jinja2_missing_input_variables(
|
||||
).input_variables == ["bar"]
|
||||
|
||||
# Test when missing in prefix
|
||||
with pytest.warns(UserWarning):
|
||||
with pytest.warns(UserWarning, match="Missing variables: {'foo'}"):
|
||||
FewShotPromptTemplate(
|
||||
input_variables=["bar"],
|
||||
suffix=suffix,
|
||||
@@ -311,7 +311,7 @@ def test_prompt_jinja2_extra_input_variables(
|
||||
"""Test error is raised when there are too many input variables."""
|
||||
prefix = "Starting with {{ foo }}"
|
||||
suffix = "Ending with {{ bar }}"
|
||||
with pytest.warns(UserWarning):
|
||||
with pytest.warns(UserWarning, match="Extra variables:"):
|
||||
FewShotPromptTemplate(
|
||||
input_variables=["bar", "foo", "extra", "thing"],
|
||||
suffix=suffix,
|
||||
|
@@ -509,7 +509,7 @@ def test_prompt_jinja2_missing_input_variables() -> None:
|
||||
"""Test error is raised when input variables are not provided."""
|
||||
template = "This is a {{ foo }} test."
|
||||
input_variables: list = []
|
||||
with pytest.warns(UserWarning):
|
||||
with pytest.warns(UserWarning, match="Missing variables: {'foo'}"):
|
||||
PromptTemplate(
|
||||
input_variables=input_variables,
|
||||
template=template,
|
||||
@@ -526,7 +526,7 @@ def test_prompt_jinja2_extra_input_variables() -> None:
|
||||
"""Test error is raised when there are too many input variables."""
|
||||
template = "This is a {{ foo }} test."
|
||||
input_variables = ["foo", "bar"]
|
||||
with pytest.warns(UserWarning):
|
||||
with pytest.warns(UserWarning, match="Extra variables: {'bar'}"):
|
||||
PromptTemplate(
|
||||
input_variables=input_variables,
|
||||
template=template,
|
||||
@@ -543,7 +543,9 @@ def test_prompt_jinja2_wrong_input_variables() -> None:
|
||||
"""Test error is raised when name of input variable is wrong."""
|
||||
template = "This is a {{ foo }} test."
|
||||
input_variables = ["bar"]
|
||||
with pytest.warns(UserWarning):
|
||||
with pytest.warns(
|
||||
UserWarning, match="Missing variables: {'foo'} Extra variables: {'bar'}"
|
||||
):
|
||||
PromptTemplate(
|
||||
input_variables=input_variables,
|
||||
template=template,
|
||||
|
@@ -10,6 +10,8 @@ class AnyStr(str):
|
||||
def __eq__(self, other: object) -> bool:
|
||||
return isinstance(other, str)
|
||||
|
||||
__hash__ = str.__hash__
|
||||
|
||||
|
||||
# The code below creates version of pydantic models
|
||||
# that will work in unit tests with AnyStr as id field
|
||||
|
@@ -884,6 +884,7 @@ def test_validation_error_handling_callable() -> None:
|
||||
],
|
||||
)
|
||||
def test_validation_error_handling_non_validation_error(
|
||||
*,
|
||||
handler: Union[
|
||||
bool, str, Callable[[Union[ValidationError, ValidationErrorV1]], str]
|
||||
],
|
||||
@@ -949,6 +950,7 @@ async def test_async_validation_error_handling_callable() -> None:
|
||||
],
|
||||
)
|
||||
async def test_async_validation_error_handling_non_validation_error(
|
||||
*,
|
||||
handler: Union[
|
||||
bool, str, Callable[[Union[ValidationError, ValidationErrorV1]], str]
|
||||
],
|
||||
@@ -2331,6 +2333,9 @@ def test_tool_return_output_mixin() -> None:
|
||||
def __eq__(self, other: object) -> bool:
|
||||
return isinstance(other, self.__class__) and self.x == other.x
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash(self.x)
|
||||
|
||||
@tool
|
||||
def foo(x: int) -> Bar:
|
||||
"""Foo."""
|
||||
|
Reference in New Issue
Block a user