Skip to content

Commit

Permalink
fixed linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
avaxaleph committed Aug 11, 2024
1 parent 81e2143 commit f41c939
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,13 @@ class FilterField(BaseModel):
criteria: FilterOps = Field(..., description="The criteria to apply for filtering.")

@field_validator("field_value", mode="before")
def validate_and_convert_datetime(cls, v) -> Union[str, int, float, bool]:
def validate_and_convert_datetime(
cls: BaseModel, v: Union[str, int, float, bool, datetime]
) -> Union[str, int, float, bool]:
"""Validate field_value and convert datetime to RFC3339 format with Z suffix.
Args:
cls (type): The class that this method is bound to.
cls (BaseModel): The class that this method is bound to.
v (Union[str, int, float, bool]): The value to be validated and converted. # noqa: DAR102: + cls
Returns:
Expand Down
9 changes: 5 additions & 4 deletions tests/connectors/document_index/test_document_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pydantic import ValidationError
from pytest import fixture, raises

from intelligence_layer.connectors.base.json_serializable import JsonSerializable
from intelligence_layer.connectors.document_index.document_index import (
CollectionPath,
DocumentContents,
Expand Down Expand Up @@ -86,7 +87,7 @@ def document_contents_with_metadata() -> list[DocumentContents]:
text_2 = """Pemberton began his professional journey by studying medicine and pharmacy. After earning a degree in pharmacy, he started his career as a druggist in Columbus, Georgia. He was known for his keen interest in creating medicinal concoctions and was well-respected in his community. His early creations included various medicines and tonics, which were typical of the times when pharmacists often concocted their own remedies."""
text_3 = """Pemberton's life took a significant turn during the American Civil War. He served as a lieutenant colonel in the Confederate Army, and it was during this period that he sustained a wound that led him to become dependent on morphine. This personal struggle with addiction likely influenced his later work in seeking out alternatives and remedies for pain relief."""

metadata_1 = {
metadata_1: JsonSerializable = {
"string-field": "example_string_1",
"integer-field": 123,
"float-field": 123.45,
Expand All @@ -96,7 +97,7 @@ def document_contents_with_metadata() -> list[DocumentContents]:
.replace("+00:00", "Z"),
}

metadata_2 = {
metadata_2: JsonSerializable = {
"string-field": "example_string_2",
"integer-field": 456,
"float-field": 678.90,
Expand All @@ -106,7 +107,7 @@ def document_contents_with_metadata() -> list[DocumentContents]:
.replace("+00:00", "Z"),
}

metadata_3 = {
metadata_3: JsonSerializable = {
"string-field": "example_string_3",
"integer-field": 789,
"float-field": 101112.13,
Expand Down Expand Up @@ -344,7 +345,7 @@ def test_create_filter_indexes_in_namespace(
namespace=aleph_alpha_namespace,
filter_index_name=index_name,
field_name=index_config["field-name"],
field_type=index_config["field-type"],
field_type=index_config["field-type"], # type:ignore[arg-type]
)

assert all(
Expand Down

0 comments on commit f41c939

Please sign in to comment.