Add pydocstyle to the ruff rules (#52136)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Harry Mellor <hej.mellor@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
@@ -223,9 +223,7 @@ class ChatCompletionContentPartVideoParam(TypedDict, total=False):
|
||||
|
||||
|
||||
class PILImage(BaseModel):
|
||||
"""
|
||||
A PIL.Image.Image object.
|
||||
"""
|
||||
"""A PIL.Image.Image object."""
|
||||
|
||||
image_pil: Image.Image
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
@@ -238,6 +236,7 @@ class CustomChatCompletionContentPILImageParam(TypedDict, total=False):
|
||||
{
|
||||
"image_pil": ImageAsset('cherry_blossom').pil_image
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
image_pil: PILImage | None
|
||||
@@ -256,6 +255,7 @@ class CustomChatCompletionContentSimpleImageParam(TypedDict, total=False):
|
||||
{
|
||||
"image_url": "https://example.com/image.jpg"
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
image_url: str | None
|
||||
@@ -273,6 +273,7 @@ class CustomChatCompletionContentSimpleAudioParam(TypedDict, total=False):
|
||||
{
|
||||
"audio_url": "https://example.com/audio.mp3"
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
audio_url: str | None
|
||||
@@ -285,6 +286,7 @@ class CustomChatCompletionContentSimpleVideoParam(TypedDict, total=False):
|
||||
{
|
||||
"video_url": "https://example.com/video.mp4"
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
video_url: str | None
|
||||
@@ -304,6 +306,7 @@ class CustomThinkCompletionContentParam(TypedDict, total=False):
|
||||
"closed": True,
|
||||
"type": "thinking"
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
thinking: Required[str]
|
||||
@@ -324,6 +327,7 @@ class CustomChatCompletionContentToolReferenceParam(TypedDict, total=False):
|
||||
"name": "get_weather",
|
||||
"type": "tool_reference"
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
name: str
|
||||
@@ -586,8 +590,7 @@ def _get_embeds_data(
|
||||
|
||||
|
||||
class BaseMultiModalItemTracker(ABC, Generic[_T]):
|
||||
"""
|
||||
Tracks multi-modal items in a given request and ensures that the number
|
||||
"""Tracks multi-modal items in a given request and ensures that the number
|
||||
of multi-modal items in a given request does not exceed the configured
|
||||
maximum per prompt.
|
||||
"""
|
||||
@@ -651,8 +654,7 @@ class BaseMultiModalItemTracker(ABC, Generic[_T]):
|
||||
return get_video_processor_cls_name(self.model_config)
|
||||
|
||||
def add(self, modality: ModalityStr, item: _T) -> str | None:
|
||||
"""
|
||||
Add a multi-modal item to the current prompt and returns the
|
||||
"""Add a multi-modal item to the current prompt and returns the
|
||||
placeholder string to use, if any.
|
||||
|
||||
An optional uuid can be added which serves as a unique identifier of the
|
||||
@@ -663,6 +665,7 @@ class BaseMultiModalItemTracker(ABC, Generic[_T]):
|
||||
pre-computed embeddings that do not go through any HF processor, encoder,
|
||||
or model-specific placeholder logic. The corresponding placeholder string is
|
||||
managed by the parser via `_add_placeholder`, so we return None here.
|
||||
|
||||
"""
|
||||
add_info = self._validate_add(modality)
|
||||
if add_info is None:
|
||||
@@ -791,13 +794,13 @@ def _resolve_items(
|
||||
mm_processor: BaseMultiModalProcessor | None,
|
||||
modality_order: dict[str, list[str]],
|
||||
) -> tuple[MultiModalDataDict, MultiModalUUIDDict]:
|
||||
"""
|
||||
Materialize the tracker's per-modality items into `mm_data` / `mm_uuids`.
|
||||
"""Materialize the tracker's per-modality items into `mm_data` / `mm_uuids`.
|
||||
|
||||
Note:
|
||||
`mm_processor` is `None` for text-only models (no registered HF
|
||||
processor) whose only modality is `prompt_embeds`. Every other
|
||||
modality requires a processor, enforced by the guard below.
|
||||
|
||||
"""
|
||||
if "image" in items_by_modality and "image_embeds" in items_by_modality:
|
||||
raise VLLMValidationError(
|
||||
@@ -1568,7 +1571,6 @@ def _get_full_multimodal_text_prompt(
|
||||
multimodal_content_part_separator: str = "\n",
|
||||
) -> str:
|
||||
"""Combine multimodal prompts for a multimodal language model."""
|
||||
|
||||
# flatten storage to make it looks like
|
||||
# {
|
||||
# "<|image|>": 2,
|
||||
@@ -1687,8 +1689,7 @@ def _collect_extra_fields(part: dict[str, Any]) -> dict[str, Any]:
|
||||
def _parse_chat_message_content_mm_part(
|
||||
part: ChatCompletionContentPartParam,
|
||||
) -> tuple[str, _ContentPart]:
|
||||
"""
|
||||
Parses a given multi-modal content part based on its type.
|
||||
"""Parses a given multi-modal content part based on its type.
|
||||
|
||||
Args:
|
||||
part: A dict containing the content part, with a potential 'type' field.
|
||||
@@ -1700,6 +1701,7 @@ def _parse_chat_message_content_mm_part(
|
||||
|
||||
Raises:
|
||||
ValueError: If the 'type' field is missing and no direct URL is found.
|
||||
|
||||
"""
|
||||
assert isinstance(
|
||||
part, dict
|
||||
|
||||
Reference in New Issue
Block a user