Skip to content

fix typing for python 3.8, fix warning #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
8 changes: 5 additions & 3 deletions aredis_om/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,12 +1378,14 @@ def outer_type_or_annotation(field: FieldInfo):
def should_index_field(field_info: Union[FieldInfo, PydanticFieldInfo]) -> bool:
# for vector, full text search, and sortable fields, we always have to index
# We could require the user to set index=True, but that would be a breaking change
index = getattr(field_info, "index", None) is True
_index = getattr(field_info, "index", None)

index = _index is True
vector_options = getattr(field_info, "vector_options", None) is not None
full_text_search = getattr(field_info, "full_text_search", None) is True
sortable = getattr(field_info, "sortable", None) is True

if index is False and any([vector_options, full_text_search, sortable]):
if _index is False and any([vector_options, full_text_search, sortable]):
log.warning(
"Field is marked as index=False, but it is a vector, full text search, or sortable field. "
"This will be ignored and the field will be indexed.",
Expand Down Expand Up @@ -1965,7 +1967,7 @@ def schema_for_type(
json_path: str,
name: str,
name_prefix: str,
typ: Union[type[RedisModel], Any],
typ: Union[Type[RedisModel], Any],
field_info: PydanticFieldInfo,
parent_type: Optional[Any] = None,
) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "redis-om"
version = "1.0.0-beta"
version = "1.0.1-beta"
description = "Object mappings, and more, for Redis."
authors = ["Redis OSS <oss@redis.com>"]
maintainers = ["Redis OSS <oss@redis.com>"]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_knn_expression.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# type: ignore
import abc
import struct
from typing import Optional
from typing import Optional, Type

import pytest_asyncio

Expand Down Expand Up @@ -42,7 +42,7 @@ def to_bytes(vectors: list[float]) -> bytes:


@py_test_mark_asyncio
async def test_vector_field(m: type[JsonModel]):
async def test_vector_field(m: Type[JsonModel]):
# Create a new instance of the Member model
vectors = [0.3 for _ in range(DIMENSIONS)]
member = m(name="seth", embeddings=[vectors])
Expand Down