Skip to content

Commit

Permalink
Add mypy support
Browse files Browse the repository at this point in the history
  • Loading branch information
ludwiktrammer committed Sep 16, 2024
1 parent 7131bbc commit 8ed90d9
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/ragbits-dev-kit/src/ragbits/dev_kit/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import jinja2
import typer
from pydantic import BaseModel
from ragbits.dev_kit.discovery.prompt_discovery import PromptDiscovery

from ragbits.common.llms import LiteLLM
from ragbits.common.llms.clients import LiteLLMOptions
from ragbits.dev_kit.discovery.prompt_discovery import PromptDiscovery


class PromptState:
Expand Down
3 changes: 1 addition & 2 deletions packages/ragbits-document-search/examples/simple_text.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import asyncio

from ragbits.common.embeddings.litellm import LiteLLMEmbeddings
from ragbits.document_search import DocumentSearch
from ragbits.document_search.documents.document import DocumentMeta
from ragbits.document_search.vector_store.in_memory import InMemoryVectorStore

from ragbits.common.embeddings.litellm import LiteLLMEmbeddings

documents = [
DocumentMeta.create_text_document_from_literal("RIP boiled water. You will be mist."),
DocumentMeta.create_text_document_from_literal(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ragbits.common.embeddings.base import Embeddings
from ragbits.document_search.documents.document import DocumentMeta
from ragbits.document_search.documents.element import Element
from ragbits.document_search.ingestion.document_processor import DocumentProcessor
Expand All @@ -7,8 +8,6 @@
from ragbits.document_search.retrieval.rerankers.noop import NoopReranker
from ragbits.document_search.vector_store.base import VectorStore

from ragbits.common.embeddings.base import Embeddings


class DocumentSearch:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Union

from pydantic import BaseModel, Field

from ragbits.document_search.documents.sources import LocalFileSource


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import ClassVar

from pydantic import BaseModel

from ragbits.document_search.documents.document import DocumentMeta
from ragbits.document_search.vector_store.base import VectorDBEntry

Expand All @@ -26,7 +27,7 @@ def get_key(self) -> str:
"""

@classmethod
def __pydantic_init_subclass__(cls, **kwargs): # pylint: disable=unused-argument
def __pydantic_init_subclass__(cls, **kwargs: dict) -> None: # pylint: disable=unused-argument
element_type_default = cls.model_fields["element_type"].default

if element_type_default is None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

from ragbits.document_search.vector_store.base import VectorDBEntry, VectorStore


Expand All @@ -7,8 +8,8 @@ class InMemoryVectorStore(VectorStore):
A simple in-memory implementation of Vector Store, storing vectors in memory.
"""

def __init__(self):
self._storage = {}
def __init__(self) -> None:
self._storage: dict[str, VectorDBEntry] = {}

async def store(self, entries: list[VectorDBEntry]) -> None:
"""
Expand Down
Empty file.
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ warn_unused_ignores = false
show_error_codes = true
check_untyped_defs = true
no_implicit_optional = true
mypy_path = ['packages']
explicit_package_bases = true
mypy_path = [
'packages/ragbits-common/src',
'packages/ragbits-dev-kit/src',
'packages/ragbits-document-search/src',
]

[[tool.mypy.overrides]]
module = "ragbits.*"
Expand Down

0 comments on commit 8ed90d9

Please sign in to comment.