From 1a3879839a2d9e0881e18cb66809564fb76724ef Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Wed, 16 Oct 2024 11:48:33 +0200 Subject: [PATCH] docs(fix): fixed warnings from griffe (#3381) # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): --- .gitignore | 1 + backend/core/quivr_core/base_config.py | 3 ++- backend/core/quivr_core/brain/brain.py | 4 ++-- backend/core/quivr_core/chat.py | 2 +- backend/core/quivr_core/config.py | 5 ----- backend/docs/pyproject.toml | 1 + 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 89fbda293..ce5464783 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,4 @@ backend/core/examples/chatbot/.chainlit/translations/en-US.json .tox Pipfile *.pkl +backend/docs/site/* diff --git a/backend/core/quivr_core/base_config.py b/backend/core/quivr_core/base_config.py index 7d7bc8163..694076021 100644 --- a/backend/core/quivr_core/base_config.py +++ b/backend/core/quivr_core/base_config.py @@ -2,6 +2,7 @@ from pathlib import Path import yaml from pydantic import BaseModel, ConfigDict +from typing import Self class QuivrBaseConfig(BaseModel): @@ -23,7 +24,7 @@ class QuivrBaseConfig(BaseModel): model_config = ConfigDict(extra="forbid") @classmethod - def from_yaml(cls, file_path: str | Path): + def from_yaml(cls, file_path: str | Path) -> Self: """ Create an instance of the class from a YAML file. diff --git a/backend/core/quivr_core/brain/brain.py b/backend/core/quivr_core/brain/brain.py index 50f20123f..53eb6c6d7 100644 --- a/backend/core/quivr_core/brain/brain.py +++ b/backend/core/quivr_core/brain/brain.py @@ -217,7 +217,7 @@ class Brain: vector_db=vector_db, ) - async def save(self, folder_path: str | Path): + async def save(self, folder_path: str | Path) -> str: """ Save the brain to a folder path. @@ -324,7 +324,7 @@ class Brain: embedder: Embeddings | None = None, skip_file_error: bool = False, processor_kwargs: dict[str, Any] | None = None, - ): + ) -> Self: """ Create a brain from a list of file paths. diff --git a/backend/core/quivr_core/chat.py b/backend/core/quivr_core/chat.py index 15da1c053..f5ea0692c 100644 --- a/backend/core/quivr_core/chat.py +++ b/backend/core/quivr_core/chat.py @@ -30,7 +30,7 @@ class ChatHistory: # TODO(@aminediro): maybe use a deque() instead ? self._msgs: list[ChatMessage] = [] - def get_chat_history(self, newest_first: bool = False): + def get_chat_history(self, newest_first: bool = False) -> List[ChatMessage]: """ Retrieves the chat history, optionally sorted in reverse chronological order. diff --git a/backend/core/quivr_core/config.py b/backend/core/quivr_core/config.py index c1abcc471..25181a40a 100644 --- a/backend/core/quivr_core/config.py +++ b/backend/core/quivr_core/config.py @@ -255,8 +255,6 @@ class LLMEndpointConfig(QuivrBaseConfig): This method sets up the initial configuration, including setting the LLM model config and API key. - Args: - **data: Keyword arguments for initializing the config. """ super().__init__(**data) self.set_llm_model_config() @@ -369,9 +367,6 @@ class RerankerConfig(QuivrBaseConfig): def __init__(self, **data): """ Initialize the RerankerConfig. - - Args: - **data: Keyword arguments for initializing the config. """ super().__init__(**data) self.validate_model() diff --git a/backend/docs/pyproject.toml b/backend/docs/pyproject.toml index 595d7000c..01de36161 100644 --- a/backend/docs/pyproject.toml +++ b/backend/docs/pyproject.toml @@ -31,6 +31,7 @@ venv_sync= "uv pip sync --python ./.venv/bin/python ./requirements.lock" venv_create_sync = {chain = ["venv_create", "venv_sync"]} check_deps = "basedpyright --project ./pyproject.toml" docs = "mkdocs serve" +build_docs = "mkdocs build --strict" [tool.basedpyright] include = ["src/"]