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:
Harry Mellor
2026-09-16 16:44:29 +00:00
committed by GitHub
co-authored by Claude Opus 5
parent 804e5377aa
commit 8c1557a79c
2002 changed files with 15024 additions and 14269 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
NOTE: This API server is used only for demonstrating usage of AsyncEngine
"""NOTE: This API server is used only for demonstrating usage of AsyncEngine
and simple performance benchmarks. It is not intended for production use.
For production use, we recommend using our OpenAI compatible server.
We are also not going to accept PRs modifying this file.
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
vLLM Chat Assistant - A Streamlit Web Interface
"""vLLM Chat Assistant - A Streamlit Web Interface.
A streamlined chat interface that quickly integrates
with vLLM API server.
@@ -78,6 +77,7 @@ def create_new_chat_session():
- current_session: Sets to new session ID
- active_session: Sets to new session ID
- messages: Resets to empty list
"""
session_id = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
st.session_state.sessions[session_id] = []
@@ -101,6 +101,7 @@ def switch_to_chat_session(session_id):
- current_session: Updated to specified session_id
- active_session: Updated to specified session_id
- messages: Loaded from sessions[session_id]
"""
st.session_state.current_session = session_id
st.session_state.active_session = session_id
@@ -134,6 +135,7 @@ def get_llm_response(messages, model, reason, content_ph=None, reasoning_ph=None
Note:
The function uses streamlit placeholders for live updates.
When reason=True, the reasoning process appears above the response.
"""
full_text = ""
think_text = ""
@@ -256,6 +258,7 @@ def server_supports_reasoning():
Returns:
bool: True if the model supports reasoning, False otherwise
"""
resp = client.chat.completions.create(
model=model,
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Retrieval Augmented Generation (RAG) Implementation with Langchain
"""Retrieval Augmented Generation (RAG) Implementation with Langchain
==================================================================
This script demonstrates a RAG implementation using LangChain, Milvus
@@ -35,6 +34,7 @@ Notes:
- Ensure both vLLM services are running before executing
- Default ports: 8000 (embedding), 8001 (chat)
- First run may take time to download models
"""
import argparse
@@ -52,9 +52,7 @@ from langchain_text_splitters import RecursiveCharacterTextSplitter
def load_and_split_documents(config: dict[str, Any]):
"""
Load and split documents from web URL
"""
"""Load and split documents from web URL."""
try:
loader = WebBaseLoader(web_paths=(config["url"],))
docs = loader.load()
@@ -70,9 +68,7 @@ def load_and_split_documents(config: dict[str, Any]):
def init_vectorstore(config: dict[str, Any], documents: list[Document]):
"""
Initialize vector store with documents
"""
"""Initialize vector store with documents."""
return Milvus.from_documents(
documents=documents,
embedding=OpenAIEmbeddings(
@@ -86,9 +82,7 @@ def init_vectorstore(config: dict[str, Any], documents: list[Document]):
def init_llm(config: dict[str, Any]):
"""
Initialize llm
"""
"""Initialize llm."""
return ChatOpenAI(
model=config["chat_model"],
openai_api_key=config["vllm_api_key"],
@@ -97,9 +91,7 @@ def init_llm(config: dict[str, Any]):
def get_qa_prompt():
"""
Get question answering prompt template
"""
"""Get question answering prompt template."""
template = """You are an assistant for question-answering tasks.
Use the following pieces of retrieved context to answer the question.
If you don't know the answer, just say that you don't know.
@@ -112,16 +104,12 @@ Answer:
def format_docs(docs: list[Document]):
"""
Format documents for prompt
"""
"""Format documents for prompt."""
return "\n\n".join(doc.page_content for doc in docs)
def create_qa_chain(retriever: Any, llm: ChatOpenAI, prompt: PromptTemplate):
"""
Set up question answering chain
"""
"""Set up question answering chain."""
return (
{
"context": retriever | format_docs,
@@ -134,9 +122,7 @@ def create_qa_chain(retriever: Any, llm: ChatOpenAI, prompt: PromptTemplate):
def get_parser() -> argparse.ArgumentParser:
"""
Parse command line arguments
"""
"""Parse command line arguments."""
parser = argparse.ArgumentParser(description="RAG with vLLM and langchain")
# Add command line arguments
@@ -192,10 +178,7 @@ def get_parser() -> argparse.ArgumentParser:
def init_config(args: Namespace):
"""
Initialize configuration settings from command line arguments
"""
"""Initialize configuration settings from command line arguments."""
return {
"vllm_api_key": args.vllm_api_key,
"vllm_embedding_endpoint": args.vllm_embedding_endpoint,
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
RAG (Retrieval Augmented Generation) Implementation with LlamaIndex
"""RAG (Retrieval Augmented Generation) Implementation with LlamaIndex
================================================================
This script demonstrates a RAG system using:
@@ -35,6 +34,7 @@ Notes:
- Ensure both vLLM services are running before executing
- Default ports: 8000 (embedding), 8001 (chat)
- First run may take time to download models
"""
import argparse
@@ -50,7 +50,7 @@ from llama_index.vector_stores.milvus import MilvusVectorStore
def init_config(args: Namespace):
"""Initialize configuration with command line arguments"""
"""Initialize configuration with command line arguments."""
return {
"url": args.url,
"embedding_model": args.embedding_model,
@@ -66,12 +66,12 @@ def init_config(args: Namespace):
def load_documents(url: str) -> list:
"""Load and process web documents"""
"""Load and process web documents."""
return SimpleWebPageReader(html_to_text=True).load_data([url])
def setup_models(config: dict[str, Any]):
"""Configure embedding and chat models"""
"""Configure embedding and chat models."""
Settings.embed_model = OpenAILikeEmbedding(
api_base=config["embedding_endpoint"],
api_key=config["vllm_api_key"],
@@ -96,14 +96,14 @@ def setup_models(config: dict[str, Any]):
def setup_vector_store(db_path: str) -> MilvusVectorStore:
"""Initialize vector store"""
"""Initialize vector store."""
sample_emb = Settings.embed_model.get_text_embedding("test")
print(f"Embedding dimension: {len(sample_emb)}")
return MilvusVectorStore(uri=db_path, dim=len(sample_emb), overwrite=True)
def create_index(documents: list, vector_store: MilvusVectorStore):
"""Create document index"""
"""Create document index."""
storage_context = StorageContext.from_defaults(vector_store=vector_store)
return VectorStoreIndex.from_documents(
documents,
@@ -112,13 +112,13 @@ def create_index(documents: list, vector_store: MilvusVectorStore):
def query_document(index: VectorStoreIndex, question: str, top_k: int):
"""Query document with given question"""
"""Query document with given question."""
query_engine = index.as_query_engine(similarity_top_k=top_k)
return query_engine.query(question)
def get_parser() -> argparse.ArgumentParser:
"""Parse command line arguments"""
"""Parse command line arguments."""
parser = argparse.ArgumentParser(description="RAG with vLLM and LlamaIndex")
# Add command line arguments