Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.0
hooks:
- id: pyupgrade
args: ["--py39-plus"]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
Expand Down
8 changes: 4 additions & 4 deletions django_typesense/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
from operator import methodcaller
from typing import Dict, Iterable, List, Union
from collections.abc import Iterable

from django.db.models import QuerySet
from django.utils.functional import cached_property
Expand Down Expand Up @@ -68,11 +68,11 @@ class TypesenseCollection(metaclass=TypesenseCollectionMeta):
default_sorting_field: str = ""
token_separators: list = []
symbols_to_index: list = []
synonyms: List[Synonym] = []
synonyms: list[Synonym] = []

def __init__(
self,
obj: Union[object, QuerySet, Iterable] = None,
obj: object | QuerySet | Iterable = None,
many: bool = False,
data: list = None,
update_fields: list = None,
Expand Down Expand Up @@ -117,7 +117,7 @@ def get_data(self):
return data

@classmethod
def get_fields(cls) -> Dict[str, TypesenseField]:
def get_fields(cls) -> dict[str, TypesenseField]:
"""
Returns:
A dictionary of the fields names to the field definition for this collection
Expand Down
2 changes: 1 addition & 1 deletion django_typesense/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def prepare_results(self):
"""
documents = (hit['document'] for hit in self.object_list["hits"])
collection = self.model.get_collection(data=documents)
model_field_names = set((local_field.name for local_field in self.model._meta.local_fields))
model_field_names = {local_field.name for local_field in self.model._meta.local_fields}
results = []

for _data in collection.validated_data:
Expand Down
7 changes: 3 additions & 4 deletions django_typesense/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import logging
import os
from datetime import date, datetime, time
from typing import List

from django.core.exceptions import FieldError
from django.core.paginator import Paginator
Expand Down Expand Up @@ -212,9 +211,9 @@ def get_unix_timestamp(datetime_object) -> int:
def export_documents(
collection_name,
filter_by: str = None,
include_fields: List[str] = None,
exclude_fields: List[str] = None,
) -> List[dict]:
include_fields: list[str] = None,
exclude_fields: list[str] = None,
) -> list[dict]:
from django_typesense.typesense_client import client

params = {}
Expand Down