Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Nov 9, 2023
1 parent 42cdc31 commit 6223a36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: 2023-present Silvano Cerza <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
import json
import logging
from typing import Any, Dict, List, Mapping, Optional, Union

Expand All @@ -15,7 +14,6 @@
from haystack.preview.document_stores.decorator import document_store
from haystack.preview.document_stores.errors import DuplicateDocumentError
from haystack.preview.document_stores.protocols import DuplicatePolicy
from pandas import DataFrame

from elasticsearch_haystack.filters import _normalize_filters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def _normalize_filters(filters: Union[List[Dict], Dict], logical_condition="") -
if len(conditions) > 1:
conditions = _normalize_ranges(conditions)
else:
conditions = conditions[0]
# mypy is complaining we're assigning a dict to a list of dicts.
# We're ok with this as we're returning right after this.
conditions = conditions[0] # type: ignore[assignment]

if logical_condition == "$not":
return {"bool": {"must_not": conditions}}
Expand All @@ -42,7 +44,9 @@ def _parse_comparison(field: str, comparison: Union[Dict, List, str, float]) ->
if isinstance(comparison, dict):
for comparator, val in comparison.items():
if isinstance(val, DataFrame):
val = val.to_json()
# Ruff is complaining we're overriding the loop variable `var`
# but we actually want to override it. So we ignore the error.
val = val.to_json() # noqa: PLW2901
if comparator == "$eq":
if isinstance(val, list):
result.append(
Expand Down
4 changes: 1 addition & 3 deletions document_stores/elasticsearch/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
from typing import List
from unittest.mock import patch

import pandas as pd
import pytest
from haystack.preview.dataclasses.document import Document
from haystack.preview.document_stores.errors import DuplicateDocumentError
from haystack.preview.document_stores.protocols import DuplicatePolicy
from haystack.preview.testing.document_store import DocumentStoreBaseTests
from haystack.preview.errors import FilterError
import pandas as pd
import numpy as np

from elasticsearch_haystack.document_store import ElasticsearchDocumentStore

Expand Down

0 comments on commit 6223a36

Please sign in to comment.