Skip to content

Commit 16254c6

Browse files
committed
docs: clean up griffe warnings, add CI workflow, drop suppression hook
Fix the 29 griffe diagnostics that the build was previously silencing via scripts/mkdocs_hooks.py so that mkdocs build --strict passes on unmodified source. Source-level docstring fixes: * redisvl/extensions/cache/llm/semantic.py: remove stray space in filter_expression type annotations; add missing colons in the Raises blocks for update / aupdate. * redisvl/extensions/cache/llm/langcache.py: type the **kwargs documentation on update / aupdate. * redisvl/extensions/message_history/semantic_history.py: fix the hanging continuation line in the as_text Args entry. * redisvl/extensions/router/semantic.py: align Args names with the function signatures (route_name, reference_ids, keys) on add_route_references / get_route_references / delete_route_references and clean up malformed Optional() syntax. * redisvl/query/query.py: type *fields, drop the bogus self return name, add a BaseQuery return annotation on return_fields, and rename text_weights to weights in set_text_weights to match the signature. * redisvl/index/index.py: add BaseSearchIndex return annotations to from_yaml and from_dict so griffe stops flagging the Returns block. * redisvl/utils/vectorize/base.py: type the **kwargs documentation on embed / embed_many / aembed / aembed_many and add a Generator[list, None, None] return annotation on batchify. * redisvl/utils/vectorize/text/huggingface.py: type the **kwargs documentation on __init__. Build pipeline: * Drop scripts/mkdocs_hooks.py and the matching hooks: entry from mkdocs.yml. mkdocs build --strict now exits 0 with zero griffe warnings. * Add .github/workflows/docs.yml to run mkdocs build --strict on every PR that touches docs, mkdocs config, source, or this workflow, and on every push to main. Uploads the rendered site as a build artifact for review. Verified locally with mkdocs build --strict (clean) and mypy on the edited modules (clean).
1 parent 308d7ca commit 16254c6

11 files changed

Lines changed: 96 additions & 69 deletions

File tree

.github/workflows/docs.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Docs
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "docs/**"
7+
- "mkdocs.yml"
8+
- "AGENTS.md"
9+
- "redisvl/**/*.py"
10+
- "pyproject.toml"
11+
- "uv.lock"
12+
- ".readthedocs.yaml"
13+
- ".github/workflows/docs.yml"
14+
push:
15+
branches:
16+
- main
17+
18+
env:
19+
UV_VERSION: "0.7.13"
20+
21+
jobs:
22+
build:
23+
name: mkdocs build --strict
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Check out repository
27+
uses: actions/checkout@v6
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Install Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: "3.11"
35+
36+
- name: Install uv
37+
uses: astral-sh/setup-uv@v6
38+
with:
39+
version: ${{ env.UV_VERSION }}
40+
enable-cache: true
41+
python-version: "3.11"
42+
cache-dependency-glob: |
43+
pyproject.toml
44+
uv.lock
45+
46+
- name: Install docs dependencies
47+
run: uv sync --frozen --group docs
48+
49+
- name: Build docs (strict)
50+
env:
51+
DISABLE_MKDOCS_2_WARNING: "true"
52+
run: uv run mkdocs build --strict
53+
54+
- name: Upload built site
55+
if: always()
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: site
59+
path: site/
60+
retention-days: 7

mkdocs.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ plugins:
122122
- redirects:
123123
redirect_maps: {}
124124

125-
hooks:
126-
- scripts/mkdocs_hooks.py
127-
128125
markdown_extensions:
129126
- abbr
130127
- admonition

redisvl/extensions/cache/llm/langcache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def update(self, key: str, **kwargs) -> None:
569569
570570
Args:
571571
key (str): The key of the document to update.
572-
**kwargs: Field-value pairs to update.
572+
**kwargs (Any): Field-value pairs to update.
573573
574574
Raises:
575575
NotImplementedError: LangCache does not support entry updates.
@@ -587,7 +587,7 @@ async def aupdate(self, key: str, **kwargs) -> None:
587587
588588
Args:
589589
key (str): The key of the document to update.
590-
**kwargs: Field-value pairs to update.
590+
**kwargs (Any): Field-value pairs to update.
591591
592592
Raises:
593593
NotImplementedError: LangCache does not support entry updates.

redisvl/extensions/cache/llm/semantic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def check(
372372
return_fields (Optional[List[str]], optional): The fields to include
373373
in each returned result. If None, defaults to all available
374374
fields in the cached entry.
375-
filter_expression (Optional[FilterExpression]) : Optional filter expression
375+
filter_expression (Optional[FilterExpression]): Optional filter expression
376376
that can be used to filter cache results. Defaults to None and
377377
the full cache will be searched.
378378
distance_threshold (Optional[float]): The threshold for semantic
@@ -463,7 +463,7 @@ async def acheck(
463463
return_fields (Optional[List[str]], optional): The fields to include
464464
in each returned result. If None, defaults to all available
465465
fields in the cached entry.
466-
filter_expression (Optional[FilterExpression]) : Optional filter expression
466+
filter_expression (Optional[FilterExpression]): Optional filter expression
467467
that can be used to filter cache results. Defaults to None and
468468
the full cache will be searched.
469469
distance_threshold (Optional[float]): The threshold for semantic
@@ -704,8 +704,8 @@ def update(self, key: str, **kwargs) -> None:
704704
key (str): the key of the document to update using kwargs.
705705
706706
Raises:
707-
ValueError if an incorrect mapping is provided as a kwarg.
708-
TypeError if metadata is provided and not of type dict.
707+
ValueError: if an incorrect mapping is provided as a kwarg.
708+
TypeError: if metadata is provided and not of type dict.
709709
710710
.. code-block:: python
711711
@@ -745,8 +745,8 @@ async def aupdate(self, key: str, **kwargs) -> None:
745745
key (str): the key of the document to update using kwargs.
746746
747747
Raises:
748-
ValueError if an incorrect mapping is provided as a kwarg.
749-
TypeError if metadata is provided and not of type dict.
748+
ValueError: if an incorrect mapping is provided as a kwarg.
749+
TypeError: if metadata is provided and not of type dict.
750750
751751
.. code-block:: python
752752

redisvl/extensions/message_history/semantic_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def get_relevant(
202202
Args:
203203
prompt (str): The message text to search for in message history
204204
as_text (bool): Whether to return the prompts and responses as text
205-
or as JSON.
205+
or as JSON.
206206
top_k (int): The number of previous messages to return. Default is 5.
207207
session_tag (Optional[str]): Tag of the entries linked to a specific
208208
conversation session. Defaults to instance ULID.

redisvl/extensions/router/semantic.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def add_route_references(
710710
"""Add a reference(s) to an existing route.
711711
712712
Args:
713-
router_name (str): The name of the router.
713+
route_name (str): The name of the route.
714714
references (Union[str, List[str]]): The reference or list of references to add.
715715
716716
Returns:
@@ -774,8 +774,9 @@ def get_route_references(
774774
"""Get references for an existing route route.
775775
776776
Args:
777-
router_name (str): The name of the router.
778-
references (Union[str, List[str]]): The reference or list of references to add.
777+
route_name (str): The name of the route.
778+
reference_ids (List[str]): The list of reference ids to fetch.
779+
keys (List[str]): The list of fully qualified keys to fetch.
779780
780781
Returns:
781782
List[Dict[str, Any]]]: Reference objects stored
@@ -810,9 +811,9 @@ def delete_route_references(
810811
"""Get references for an existing semantic router route.
811812
812813
Args:
813-
router_name Optional(str): The name of the router.
814-
reference_ids Optional(List[str]]): The reference or list of references to delete.
815-
keys Optional(List[str]]): List of fully qualified keys (prefix:router:reference_id) to delete.
814+
route_name (Optional[str]): The name of the route.
815+
reference_ids (Optional[List[str]]): The reference or list of references to delete.
816+
keys (Optional[List[str]]): List of fully qualified keys (prefix:router:reference_id) to delete.
816817
817818
Returns:
818819
int: Number of objects deleted

redisvl/index/index.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ def storage_type(self) -> StorageType:
337337
return self.schema.index.storage_type
338338

339339
@classmethod
340-
def from_yaml(cls, schema_path: str, **kwargs):
340+
def from_yaml(cls, schema_path: str, **kwargs) -> "BaseSearchIndex":
341341
"""Create a SearchIndex from a YAML schema file.
342342
343343
Args:
344344
schema_path (str): Path to the YAML schema file.
345345
346346
Returns:
347-
SearchIndex: A RedisVL SearchIndex object.
347+
A RedisVL SearchIndex object.
348348
349349
.. code-block:: python
350350
@@ -356,14 +356,14 @@ def from_yaml(cls, schema_path: str, **kwargs):
356356
return cls(schema=schema, **kwargs)
357357

358358
@classmethod
359-
def from_dict(cls, schema_dict: dict[str, Any], **kwargs):
359+
def from_dict(cls, schema_dict: dict[str, Any], **kwargs) -> "BaseSearchIndex":
360360
"""Create a SearchIndex from a dictionary.
361361
362362
Args:
363363
schema_dict (Dict[str, Any]): A dictionary containing the schema.
364364
365365
Returns:
366-
SearchIndex: A RedisVL SearchIndex object.
366+
A RedisVL SearchIndex object.
367367
368368
.. code-block:: python
369369

redisvl/query/query.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,19 @@ def _query_string(self, value: str | None):
256256
"""Setter for _query_string to maintain compatibility with parent class."""
257257
self._built_query_string = value
258258

259-
def return_fields(self, *fields, skip_decode: str | list[str] | None = None):
259+
def return_fields(
260+
self, *fields, skip_decode: str | list[str] | None = None
261+
) -> "BaseQuery":
260262
"""
261263
Set the fields to return with search results.
262264
263265
Args:
264-
*fields: Variable number of field names to return.
266+
*fields (str): Variable number of field names to return.
265267
skip_decode: Optional field name or list of field names that should not be
266268
decoded. Useful for binary data like embeddings.
267269
268270
Returns:
269-
self: Returns the query object for method chaining.
271+
The query object for method chaining.
270272
271273
Raises:
272274
TypeError: If skip_decode is not a string, list, or None.
@@ -1593,7 +1595,7 @@ def set_text_weights(self, weights: dict[str, float]):
15931595
"""Set or update the text weights for the query.
15941596
15951597
Args:
1596-
text_weights: Dictionary of word:weight mappings
1598+
weights: Dictionary of word:weight mappings
15971599
"""
15981600
self._text_weights = self._parse_text_weights(weights)
15991601
self._built_query_string = None

redisvl/utils/vectorize/base.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
from enum import Enum
44
from pathlib import Path
5-
from typing import Annotated, Any, Callable
5+
from typing import Annotated, Any, Callable, Generator
66

77
from pydantic import BaseModel, ConfigDict, Field, field_validator
88

@@ -85,7 +85,7 @@ def embed(
8585
preprocess: Function to apply to the content before embedding
8686
as_buffer: Return the embedding as a binary buffer instead of a list
8787
skip_cache: Bypass the cache for this request
88-
**kwargs: Additional model-specific parameters
88+
**kwargs (Any): Additional model-specific parameters
8989
9090
Returns:
9191
The vector embedding as either a list of floats or binary buffer
@@ -155,7 +155,7 @@ def embed_many(
155155
batch_size: Number of items to process in each API call
156156
as_buffer: Return embeddings as binary buffers instead of lists
157157
skip_cache: Bypass the cache for this request
158-
**kwargs: Additional model-specific parameters
158+
**kwargs (Any): Additional model-specific parameters
159159
160160
Returns:
161161
List of vector embeddings in the same order as the inputs
@@ -215,7 +215,7 @@ async def aembed(
215215
preprocess: Function to apply to the content before embedding
216216
as_buffer: Return the embedding as a binary buffer instead of a list
217217
skip_cache: Bypass the cache for this request
218-
**kwargs: Additional model-specific parameters
218+
**kwargs (Any): Additional model-specific parameters
219219
220220
Returns:
221221
The vector embedding as either a list of floats or binary buffer
@@ -288,7 +288,7 @@ async def aembed_many(
288288
batch_size: Number of texts to process in each API call
289289
as_buffer: Return embeddings as binary buffers instead of lists
290290
skip_cache: Bypass the cache for this request
291-
**kwargs: Additional model-specific parameters
291+
**kwargs (Any): Additional model-specific parameters
292292
293293
Returns:
294294
List of vector embeddings in the same order as the inputs
@@ -532,7 +532,9 @@ async def _astore_in_cache_batch(
532532
f"Error storing batch in embedding cache asynchronously: {str(e)}"
533533
)
534534

535-
def batchify(self, seq: list, size: int, preprocess: Callable | None = None):
535+
def batchify(
536+
self, seq: list, size: int, preprocess: Callable | None = None
537+
) -> Generator[list, None, None]:
536538
"""Split a sequence into batches of specified size.
537539
538540
Args:
@@ -541,7 +543,7 @@ def batchify(self, seq: list, size: int, preprocess: Callable | None = None):
541543
preprocess: Optional function to preprocess each item
542544
543545
Yields:
544-
Batches of the sequence
546+
Batches of the sequence.
545547
"""
546548
for pos in range(0, len(seq), size):
547549
if preprocess is not None:

redisvl/utils/vectorize/text/huggingface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(
8989
Defaults to 'float32'.
9090
cache (Optional[EmbeddingsCache]): Optional EmbeddingsCache instance to cache embeddings for
9191
better performance with repeated texts. Defaults to None.
92-
**kwargs: Additional parameters to pass to the SentenceTransformer
92+
**kwargs (Any): Additional parameters to pass to the SentenceTransformer
9393
constructor.
9494
9595
Raises:

0 commit comments

Comments
 (0)