Skip to content

Commit

Permalink
Fix pylint failures
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Nov 11, 2024
1 parent dd28cc1 commit 5849da3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions haystack/document_stores/mongodb_atlas.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import re
from typing import Dict, Generator, List, Optional, Union

import numpy as np
from tqdm import tqdm

from haystack import __version__ as haystack_version
from haystack.document_stores import BaseDocumentStore
from haystack.errors import DocumentStoreError
from haystack.nodes.retriever import DenseRetriever
from haystack.schema import Document, FilterType
from haystack.utils import get_batches_from_generator
from haystack import __version__ as haystack_version
from .mongodb_filters import mongo_filter_converter

from ..lazy_imports import LazyImport
from .mongodb_filters import mongo_filter_converter

with LazyImport("Run 'pip install farm-haystack[mongodb]'") as mongodb_import:
import pymongo
import pymongo.collection.Collection
from pymongo import InsertOne, ReplaceOne, UpdateOne
from pymongo.collection import Collection as MongoCollection
from pymongo.driver_info import DriverInfo

METRIC_TYPES = ["euclidean", "cosine", "dotProduct"]
Expand Down Expand Up @@ -83,7 +86,7 @@ def __init__(
def _create_document_field_map(self) -> Dict:
return {self.embedding_field: "embedding"}

def _get_collection(self, index=None) -> "pymongo.collection.Collection":
def _get_collection(self, index=None) -> "MongoCollection":
"""
Returns the collection named by index or returns the collection specified when the
driver was initialized.
Expand Down Expand Up @@ -127,7 +130,7 @@ def delete_documents(
elif (ids, filters) == (ids, filters):
mongo_filters = {"$and": [mongo_filter_converter(filters), {"id": {"$in": ids}}]}

collection.delete_many(filter=mongo_filters)
collection.delete_many(filter=mongo_filters) # pylint: disable=possibly-used-before-assignment

def delete_index(self, index=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion haystack/modeling/model/language_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _pool_tokens(
if strategy == "reduce_mean":
pooled_vecs = np.ma.array(data=token_vecs, mask=ignore_mask_3d).mean(axis=1).data

return pooled_vecs
return pooled_vecs # pylint: disable=possibly-used-before-assignment


class HFLanguageModel(LanguageModel):
Expand Down

0 comments on commit 5849da3

Please sign in to comment.