fix: improve type narrowing in Knowledge.query with local variable

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2024-12-27 20:54:14 +00:00
parent b56c4c52c0
commit 2d23ef7e12

View File

@@ -53,10 +53,11 @@ class Knowledge(BaseModel):
Raises:
ValueError: If no storage is configured for querying.
"""
if self.storage is None:
storage = self.storage
if storage is None:
raise ValueError("No storage found to perform query.")
results = self.storage.search(
# Assign to local variable to help mypy with type narrowing
results = storage.search(
query,
limit,
)