core: Add ruff rules for pycodestyle Warning (W) (#26964)

All auto-fixes.
This commit is contained in:
Christophe Bornet
2024-09-30 15:31:43 +02:00
committed by GitHub
parent 9404e7af9d
commit db8845a62a
32 changed files with 119 additions and 119 deletions

View File

@@ -65,7 +65,7 @@ class RunnableConfig(TypedDict, total=False):
max_concurrency: Optional[int]
"""
Maximum number of parallel calls to make. If not provided, defaults to
Maximum number of parallel calls to make. If not provided, defaults to
ThreadPoolExecutor's default.
"""
@@ -78,7 +78,7 @@ class RunnableConfig(TypedDict, total=False):
"""
Runtime values for attributes previously made configurable on this Runnable,
or sub-Runnables, through .configurable_fields() or .configurable_alternatives().
Check .output_schema() for a description of the attributes that have been made
Check .output_schema() for a description of the attributes that have been made
configurable.
"""

View File

@@ -538,7 +538,7 @@ class RunnableConfigurableAlternatives(DynamicRunnable[Input, Output]):
prefix_keys: bool
"""Whether to prefix configurable fields of each alternative with a namespace
of the form <which.id>==<alternative_key>, eg. a key named "temperature" used by
of the form <which.id>==<alternative_key>, eg. a key named "temperature" used by
the alternative named "gpt3" becomes "model==gpt3/temperature"."""
@classmethod

View File

@@ -93,13 +93,13 @@ class RunnableWithFallbacks(RunnableSerializable[Input, Output]):
"""A sequence of fallbacks to try."""
exceptions_to_handle: tuple[type[BaseException], ...] = (Exception,)
"""The exceptions on which fallbacks should be tried.
Any exception that is not a subclass of these exceptions will be raised immediately.
"""
exception_key: Optional[str] = None
"""If string is specified then handled exceptions will be passed to fallbacks as
"""If string is specified then handled exceptions will be passed to fallbacks as
part of the input under the specified key. If None, exceptions
will not be passed to fallbacks. If used, the base Runnable and its fallbacks
will not be passed to fallbacks. If used, the base Runnable and its fallbacks
must accept a dictionary as input."""
model_config = ConfigDict(

View File

@@ -96,10 +96,10 @@ class RunnableRetry(RunnableBindingBase[Input, Output]):
retry_exception_types: tuple[type[BaseException], ...] = (Exception,)
"""The exception types to retry on. By default all exceptions are retried.
In general you should only retry on exceptions that are likely to be
transient, such as network errors.
Good exceptions to retry are all server errors (5xx) and selected client
errors (4xx) such as 429 Too Many Requests.
"""

View File

@@ -13,26 +13,26 @@ class EventData(TypedDict, total=False):
input: Any
"""The input passed to the Runnable that generated the event.
Inputs will sometimes be available at the *START* of the Runnable, and
Inputs will sometimes be available at the *START* of the Runnable, and
sometimes at the *END* of the Runnable.
If a Runnable is able to stream its inputs, then its input by definition
won't be known until the *END* of the Runnable when it has finished streaming
its inputs.
"""
output: Any
"""The output of the Runnable that generated the event.
Outputs will only be available at the *END* of the Runnable.
For most Runnables, this field can be inferred from the `chunk` field,
though there might be some exceptions for special cased Runnables (e.g., like
chat models), which may return more information.
"""
chunk: Any
"""A streaming chunk from the output that generated the event.
chunks support addition in general, and adding them up should result
in the output of the Runnable that generated the event.
"""
@@ -85,49 +85,49 @@ class BaseStreamEvent(TypedDict):
event: str
"""Event names are of the format: on_[runnable_type]_(start|stream|end).
Runnable types are one of:
- **llm** - used by non chat models
- **chat_model** - used by chat models
- **prompt** -- e.g., ChatPromptTemplate
- **tool** -- from tools defined via @tool decorator or inheriting
from Tool/BaseTool
- **chain** - most Runnables are of this type
Further, the events are categorized as one of:
- **start** - when the Runnable starts
- **stream** - when the Runnable is streaming
- **end* - when the Runnable ends
start, stream and end are associated with slightly different `data` payload.
Please see the documentation for `EventData` for more details.
"""
run_id: str
"""An randomly generated ID to keep track of the execution of the given Runnable.
Each child Runnable that gets invoked as part of the execution of a parent Runnable
is assigned its own unique ID.
"""
tags: NotRequired[list[str]]
"""Tags associated with the Runnable that generated this event.
Tags are always inherited from parent Runnables.
Tags can either be bound to a Runnable using `.with_config({"tags": ["hello"]})`
or passed at run time using `.astream_events(..., {"tags": ["hello"]})`.
"""
metadata: NotRequired[dict[str, Any]]
"""Metadata associated with the Runnable that generated this event.
Metadata can either be bound to a Runnable using
Metadata can either be bound to a Runnable using
`.with_config({"metadata": { "foo": "bar" }})`
or passed at run time using
or passed at run time using
`.astream_events(..., {"metadata": {"foo": "bar"}})`.
"""
@@ -136,11 +136,11 @@ class BaseStreamEvent(TypedDict):
Root Events will have an empty list.
For example, if a Runnable A calls Runnable B, then the event generated by Runnable
For example, if a Runnable A calls Runnable B, then the event generated by Runnable
B will have Runnable A's ID in the parent_ids field.
The order of the parent IDs is from the root parent to the immediate parent.
Only supported as of v2 of the astream events API. v1 will return an empty list.
"""