DSPy: The framework for programming—not prompting—language models
Python
Fix TID252 and F401 violation (#7871)
TomuHirata13f086c2ff8c
diff --git a/dspy/clients/lm_local.py b/dspy/clients/lm_local.pyindex 3aa2465f9..a9401fb49 100644--- a/dspy/clients/lm_local.py+++ b/dspy/clients/lm_local.py@@ -25,7 +25,7 @@ class LocalProvider(Provider):@staticmethoddef launch(lm: "LM", launch_kwargs: Optional[Dict[str, Any]] = None):try:- import sglang+ import sglang # noqa: F401except ImportError:raise ImportError("For local model launching, please install sglang by running "diff --git a/dspy/dsp/colbertv2.py b/dspy/dsp/colbertv2.pyindex 6b1fd8cb3..5ffaeb9f2 100644--- a/dspy/dsp/colbertv2.py+++ b/dspy/dsp/colbertv2.py@@ -103,7 +103,7 @@ class ColBERTv2RetrieverLocal:def build_index(self):try:- import colbert+ import colbert # noqa: F401except ImportError:print("Colbert not found. Please check your installation or install the module using pip install colbert-ai[faiss-gpu,torch].")@@ -115,7 +115,7 @@ class ColBERTv2RetrieverLocal:def get_index(self):try:- import colbert+ import colbert # noqa: F401except ImportError:print("Colbert not found. Please check your installation or install the module using pip install colbert-ai[faiss-gpu,torch].")@@ -154,7 +154,7 @@ class ColBERTv2RerankerLocal:def __init__(self,colbert_config=None,checkpoint:str='bert-base-uncased'):try:- import colbert+ import colbert # noqa: F401except ImportError:print("Colbert not found. Please check your installation or install the module using pip install colbert-ai[faiss-gpu,torch].")"""_summary_diff --git a/dspy/predict/multi_chain_comparison.py b/dspy/predict/multi_chain_comparison.pyindex db7b279cc..f91bb0c49 100644--- a/dspy/predict/multi_chain_comparison.py+++ b/dspy/predict/multi_chain_comparison.py@@ -1,8 +1,8 @@-import dspy+from dspy.signatures import InputField, OutputFieldfrom dspy.signatures.signature import ensure_signature-from ..primitives.program import Module-from .predict import Predict+from dspy.primitives.program import Module+from dspy.predict.predict import Predictclass MultiChainComparison(Module):@@ -17,14 +17,14 @@ class MultiChainComparison(Module):for idx in range(M):signature = signature.append(f"reasoning_attempt_{idx+1}",- dspy.InputField(+ InputField(prefix=f"Student Attempt #{idx+1}:", desc="${reasoning attempt}",),)signature = signature.prepend("rationale",- dspy.OutputField(+ OutputField(prefix="Accurate Reasoning: Thank you everyone. Let's now holistically",desc="${corrected reasoning}",),diff --git a/dspy/predict/parallel.py b/dspy/predict/parallel.pyindex 78ef3e8ea..f7cb6bbb8 100644--- a/dspy/predict/parallel.py+++ b/dspy/predict/parallel.py@@ -2,8 +2,8 @@ import threadingfrom typing import Tuple, List, Any-from ..primitives.example import Example-from ..utils.parallelizer import ParallelExecutor+from dspy.primitives.example import Example+from dspy.utils.parallelizer import ParallelExecutorclass Parallel:diff --git a/dspy/predict/program_of_thought.py b/dspy/predict/program_of_thought.pyindex 4534d98cf..a6d6a8e42 100644--- a/dspy/predict/program_of_thought.py+++ b/dspy/predict/program_of_thought.py@@ -3,8 +3,8 @@ import reimport dspyfrom dspy.signatures.signature import ensure_signature-from ..primitives.program import Module-from ..primitives.python_interpreter import PythonInterpreter+from dspy.primitives.program import Module+from dspy.primitives.python_interpreter import PythonInterpreterclass ProgramOfThought(Module):diff --git a/dspy/retrieve/chromadb_rm.py b/dspy/retrieve/chromadb_rm.pyindex ee6219ba9..c102f8565 100644--- a/dspy/retrieve/chromadb_rm.py+++ b/dspy/retrieve/chromadb_rm.py@@ -25,7 +25,6 @@ try:EmbeddingFunction,)from chromadb.config import Settings- from chromadb.utils import embedding_functionsexcept ImportError:raise ImportError("The chromadb library is required to use ChromadbRM. Install it with `pip install dspy-ai[chromadb]`",diff --git a/dspy/retrieve/deeplake_rm.py b/dspy/retrieve/deeplake_rm.pyindex 3bb134015..a126941dd 100644--- a/dspy/retrieve/deeplake_rm.py+++ b/dspy/retrieve/deeplake_rm.py@@ -57,7 +57,7 @@ class DeeplakeRM(dspy.Retrieve):k: int = 3,):try:- from deeplake import VectorStore+ from deeplake import VectorStore # noqa: F401except ImportError:raise ImportError("The 'deeplake' extra is required to use DeepLakeRM. Install it with `pip install dspy-ai[deeplake]`",)