Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/custom_output_files/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def mutate(

@cocoindex.op.function()
def markdown_to_html(text: str) -> str:
return _markdown_it.render(text) # type: ignore
return _markdown_it.render(text)


@cocoindex.flow_def(name="CustomOutputFiles")
Expand Down
2 changes: 1 addition & 1 deletion examples/face_recognition/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def extract_face_embedding(
np.array(img),
known_face_locations=[(0, img.width - 1, img.height - 1, 0)],
)[0]
return embedding # type: ignore
return embedding


@cocoindex.flow_def(name="FaceRecognition")
Expand Down
2 changes: 1 addition & 1 deletion examples/fastapi_server_docker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
fastapi_app = FastAPI(lifespan=lifespan)


@fastapi_app.get("/search") # type: ignore
@fastapi_app.get("/search")
def search_endpoint(
request: Request,
q: str = Query(..., description="Search query"),
Expand Down
2 changes: 1 addition & 1 deletion examples/image_search/colpali_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:


# --- Search API ---
@app.get("/search") # type: ignore
@app.get("/search")
def search(
q: str = Query(..., description="Search query"),
limit: int = Query(5, description="Number of results"),
Expand Down
6 changes: 3 additions & 3 deletions examples/image_search/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def embed_query(text: str) -> list[float]:
inputs = processor(text=[text], return_tensors="pt", padding=True)
with torch.no_grad():
features = model.get_text_features(**inputs)
return features[0].tolist() # type: ignore
return features[0].tolist()


@cocoindex.op.function(cache=True, behavior_version=1, gpu=True)
Expand All @@ -51,7 +51,7 @@ def embed_image(
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
features = model.get_image_features(**inputs)
return features[0].tolist() # type: ignore
return features[0].tolist()


# CocoIndex flow: Ingest images, extract captions, embed, export to Qdrant
Expand Down Expand Up @@ -140,7 +140,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:


# --- Search API ---
@app.get("/search") # type: ignore
@app.get("/search")
def search(
q: str = Query(..., description="Search query"),
limit: int = Query(5, description="Number of results"),
Expand Down
3 changes: 1 addition & 2 deletions examples/manuals_llm_extraction/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from marker.models import create_model_dict
from marker.output import text_from_rendered
from marker.config.parser import ConfigParser
from typing import cast

import cocoindex

Expand All @@ -32,7 +31,7 @@ def __call__(self, content: bytes) -> str:
temp_file.write(content)
temp_file.flush()
text_any, _, _ = text_from_rendered(self._converter(temp_file.name))
return cast(str, text_any)
return text_any


@dataclasses.dataclass
Expand Down
3 changes: 1 addition & 2 deletions examples/paper_metadata/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from marker.models import create_model_dict
from marker.output import text_from_rendered
from functools import cache
from typing import cast
from pypdf import PdfReader, PdfWriter


Expand Down Expand Up @@ -68,7 +67,7 @@ def pdf_to_markdown(content: bytes) -> str:
temp_file.write(content)
temp_file.flush()
text_any, _, _ = text_from_rendered(get_marker_converter()(temp_file.name))
return cast(str, text_any)
return text_any


@cocoindex.flow_def(name="PaperMetadata")
Expand Down
8 changes: 4 additions & 4 deletions examples/patient_intake_extraction_dspy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Patient(BaseModel):


# DSPy Signature for patient information extraction from images
class PatientExtractionSignature(dspy.Signature): # type: ignore[misc]
class PatientExtractionSignature(dspy.Signature):
"""Extract structured patient information from a medical intake form image."""

form_images: list[dspy.Image] = dspy.InputField(
Expand All @@ -88,7 +88,7 @@ class PatientExtractionSignature(dspy.Signature): # type: ignore[misc]
)


class PatientExtractor(dspy.Module): # type: ignore[misc]
class PatientExtractor(dspy.Module):
"""DSPy module for extracting patient information from intake form images."""

def __init__(self) -> None:
Expand All @@ -98,7 +98,7 @@ def __init__(self) -> None:
def forward(self, form_images: list[dspy.Image]) -> Patient:
"""Extract patient information from form images and return as a Pydantic model."""
result = self.extract(form_images=form_images)
return result.patient # type: ignore
return result.patient


@cocoindex.op.function(cache=True, behavior_version=1)
Expand All @@ -123,7 +123,7 @@ def extract_patient(pdf_content: bytes) -> Patient:
extractor = PatientExtractor()
patient = extractor(form_images=form_images)

return patient # type: ignore
return patient


@cocoindex.flow_def(name="PatientIntakeExtractionDSPy")
Expand Down
5 changes: 2 additions & 3 deletions examples/pdf_elements_embedding/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dataclasses import dataclass
from pypdf import PdfReader
from transformers import CLIPModel, CLIPProcessor
from typing import cast


QDRANT_GRPC_URL = "http://localhost:6334"
Expand Down Expand Up @@ -36,7 +35,7 @@ def clip_embed_image(img_bytes: bytes) -> list[float]:
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
features = model.get_image_features(**inputs)
return cast(list[float], features[0].tolist())
return features[0].tolist()


def clip_embed_query(text: str) -> list[float]:
Expand All @@ -47,7 +46,7 @@ def clip_embed_query(text: str) -> list[float]:
inputs = processor(text=[text], return_tensors="pt", padding=True)
with torch.no_grad():
features = model.get_text_features(**inputs)
return cast(list[float], features[0].tolist())
return features[0].tolist()


@cocoindex.transform_flow()
Expand Down
2 changes: 1 addition & 1 deletion examples/pdf_embedding/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __call__(self, content: bytes) -> str:
temp_file.write(content)
temp_file.flush()
text_any, _, _ = text_from_rendered(self._converter(temp_file.name))
return text_any # type: ignore
return text_any


@cocoindex.transform_flow()
Expand Down
4 changes: 2 additions & 2 deletions examples/postgres_source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dotenv import load_dotenv
from psycopg_pool import ConnectionPool
from pgvector.psycopg import register_vector # type: ignore[import-untyped]
from pgvector.psycopg import register_vector
from psycopg.rows import dict_row
from numpy.typing import NDArray

Expand Down Expand Up @@ -133,7 +133,7 @@ def search(pool: ConnectionPool, query: str, top_k: int = 5) -> list[dict[str, A
""",
(query_vector, top_k),
)
return cur.fetchall() # type: ignore
return cur.fetchall()


def _main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ignore_missing_imports = true
module = ["examples.*"]

# Silence missing import errors for optional dependencies
disable_error_code = ["import-not-found", "import-untyped", "no-any-return"]
disable_error_code = ["import-not-found", "import-untyped", "untyped-decorator"]

# Prevent the "Any" contagion from triggering strict errors
# (These flags are normally True in strict mode)
Expand Down
2 changes: 1 addition & 1 deletion python/cocoindex/functions/colpali.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ColPaliModelInfo:
def _get_colpali_model_and_processor(model_name: str) -> ColPaliModelInfo:
"""Load and cache ColPali model and processor with shared device setup."""
try:
import colpali_engine as ce # type: ignore[import-untyped]
import colpali_engine as ce
import torch
except ImportError as e:
raise ImportError(
Expand Down
Loading