Skip to content

Commit f4c4827

Browse files
committed
lint
1 parent e8eb7f5 commit f4c4827

File tree

9 files changed

+25
-21
lines changed

9 files changed

+25
-21
lines changed

guardrails/actions/reask.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ def get_reask_setup_for_string(
297297
if messages is None:
298298
messages = Messages(
299299
[
300-
{"role": "system", "content": instructions},
301-
{"role": "user", "content": prompt}]
300+
{"role": "system", "content": instructions},
301+
{"role": "user", "content": prompt},
302+
]
302303
)
303304

304305
messages = messages.format(

guardrails/classes/history/call.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def prompt_params(self) -> Optional[Dict]:
7979

8080
@property
8181
def messages(self) -> Optional[Union[Messages, list[dict[str, str]]]]:
82-
"""The messages as provided by the user when initializing or calling the
83-
Guard."""
82+
"""The messages as provided by the user when initializing or calling
83+
the Guard."""
8484
return self.inputs.messages
8585

8686
@property

guardrails/run/async_stream_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def async_step(
200200
def get_chunk_text(self, chunk: Any, api: Union[PromptCallableBase, None]) -> str:
201201
"""Get the text from a chunk."""
202202
chunk_text = ""
203-
203+
204204
try:
205205
finished = chunk.choices[0].finish_reason
206206
content = chunk.choices[0].delta.content

guardrails/run/stream_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from guardrails.classes.output_type import OT, OutputTypes
66
from guardrails.classes.validation_outcome import ValidationOutcome
77
from guardrails.llm_providers import (
8-
LiteLLMCallable,
98
PromptCallableBase,
109
)
1110
from guardrails.run.runner import Runner

tests/integration_tests/test_assets/custom_llm.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from typing import Dict, List, Optional
2-
3-
41
def mock_llm(
52
messages,
63
*args,

tests/integration_tests/test_assets/lists_object.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ class Item(BaseModel):
1616
PYDANTIC_RAIL_WITH_LIST = List[Item]
1717

1818

19-
RAIL_SPEC_WITH_LIST = """
19+
message = (
20+
'<message role="user">'
21+
"Create a list of items that may be found in a grocery store."
22+
"</message>"
23+
)
24+
RAIL_SPEC_WITH_LIST = f"""
2025
<rail version="0.1">
2126
<output type="list">
2227
<object>
@@ -25,7 +30,7 @@ class Item(BaseModel):
2530
</object>
2631
</output>
2732
<messages>
28-
<message role="user">Create a list of items that may be found in a grocery store.</message>
33+
{message}
2934
</messages>
3035
</rail>
3136
"""

tests/integration_tests/test_formatters.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ class Foo(BaseModel):
2525
bez: List[str]
2626

2727
g = Guard.from_pydantic(Foo, output_formatter="jsonformer")
28-
response = g(model.generate, tokenizer=tokenizer, messages=[{"content": "test","role": "user"}])
28+
response = g(
29+
model.generate,
30+
tokenizer=tokenizer,
31+
messages=[{"content": "test", "role": "user"}],
32+
)
2933
validated_output = response.validated_output
3034
assert isinstance(validated_output, dict)
3135
assert "bar" in validated_output
@@ -45,7 +49,7 @@ class Foo(BaseModel):
4549
bez: List[str]
4650

4751
g = Guard.from_pydantic(Foo, output_formatter="jsonformer")
48-
response = g(model, messages=[{"content": "Sample:","role": "user"}])
52+
response = g(model, messages=[{"content": "Sample:", "role": "user"}])
4953
validated_output = response.validated_output
5054
assert isinstance(validated_output, dict)
5155
assert "bar" in validated_output

tests/unit_tests/actions/test_reask.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,7 @@ def test_get_reask_prompt(
550550
]
551551
)
552552

553-
(
554-
reask_schema,
555-
reask_messages
556-
) = get_reask_setup(
553+
(reask_schema, reask_messages) = get_reask_setup(
557554
output_type,
558555
output_schema,
559556
validation_map={},

tests/unit_tests/test_validator_base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,9 @@ def mock_llm_api(messages, *args, **kwargs):
485485
}
486486
],
487487
)
488-
assert str(excinfo.value) == "Validation failed for field with errors: must be exactly two words"
488+
assert str(excinfo.value) == (
489+
"Validation failed for field with errors:" " must be exactly two words"
490+
)
489491
assert isinstance(guard.history.first.exception, ValidationError)
490492
assert guard.history.first.exception == excinfo.value
491493

@@ -565,8 +567,8 @@ async def mock_llm_api(messages, *args, **kwargs) -> str:
565567
}
566568
],
567569
)
568-
569-
assert guard.history.first.iterations.first.outputs.validation_response == "What kind"
570+
first_iter = guard.history.first.iterations.first
571+
assert first_iter.outputs.validation_response == "What kind"
570572

571573
# rail prompt validation
572574
guard = AsyncGuard.from_rail_string(
@@ -767,4 +769,3 @@ async def custom_llm(messages, *args, **kwargs) -> str:
767769
assert str(excinfo.value) == unstructured_messages_error
768770
assert isinstance(guard.history.last.exception, ValidationError)
769771
assert guard.history.last.exception == excinfo.value
770-

0 commit comments

Comments
 (0)