core: Add ruff rules D (docstring) (#29406)

This ensures that the code is properly documented:
https://docs.astral.sh/ruff/rules/#pydocstyle-d

Related to #21983
This commit is contained in:
Christophe Bornet
2025-04-01 19:15:45 +02:00
committed by GitHub
parent 64df60e690
commit 88b4233fa1
120 changed files with 1152 additions and 444 deletions

View File

@@ -1,4 +1,6 @@
"""**Document** module is a collection of classes that handle documents
"""Documents module.
**Document** module is a collection of classes that handle documents
and their transformations.
"""

View File

@@ -1,3 +1,5 @@
"""Base classes for media and documents."""
from __future__ import annotations
import contextlib
@@ -45,6 +47,11 @@ class BaseMedia(Serializable):
@field_validator("id", mode="before")
def cast_id_to_str(cls, id_value: Any) -> Optional[str]:
"""Coerce the id field to a string.
Args:
id_value: The id value to coerce.
"""
if id_value is not None:
return str(id_value)
else:
@@ -291,7 +298,10 @@ class Document(BaseMedia):
@classmethod
def get_lc_namespace(cls) -> list[str]:
"""Get the namespace of the langchain object."""
"""Get the namespace of the langchain object.
Default namespace is ["langchain", "schema", "document"].
"""
return ["langchain", "schema", "document"]
def __str__(self) -> str:

View File

@@ -1,3 +1,5 @@
"""Document compressor."""
from __future__ import annotations
from abc import ABC, abstractmethod

View File

@@ -1,3 +1,5 @@
"""Document transformers."""
from __future__ import annotations
from abc import ABC, abstractmethod