pymupdf / RAG

RAG (Retrieval-Augmented Generation) Chatbot Examples Using PyMuPDF
https://pymupdf.readthedocs.io/en/latest/pymupdf4llm
GNU Affero General Public License v3.0
539 stars 82 forks source link

typing errors #39

Closed fareshan closed 4 months ago

fareshan commented 5 months ago

How do you handle these Pyright typing errors ?

error: Argument of type "Document" cannot be assigned to parameter "doc" of type "str" in function "to_markdown"
    "Document" is incompatible with "str" (reportArgumentType)

error: Argument of type "list[int] | None" cannot be assigned to parameter "pages" of type "list[Unknown]" in function "to_markdown"
    Type "list[int] | None" cannot be assigned to type "list[Unknown]"
      "None" is incompatible with "list[Unknown]" (reportArgumentType)
def extract_text_as_markdown(
    pdf_document: fitz.Document,
    page_nbr: int | None,
) -> str:
    try:
        page_list = [page_nbr] if page_nbr else None
        md_text = pymupdf4llm.to_markdown(
            doc=pdf_document,
            pages=page_list,
            hdr_info=None,
            write_images=False,
            page_chunks=False,
        )

Python version: 3.11.7

JorjMcKie commented 5 months ago

We will fall back to typing.Any in all those cases - or remove any typing specifications altogether. The features in this repo are still early in their development, so we don't want to bother ourselves too much now with these things.

JorjMcKie commented 4 months ago

Closing this for now. We will turn to this question at a later pint in time.