Skip to content

Commit 7ca997c

Browse files
authored
fix typing for python 3.8, fix warning (#698)
* fix typing for python 3.8, fix warning * bump version
1 parent cd117b2 commit 7ca997c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

aredis_om/model/model.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,12 +1378,14 @@ def outer_type_or_annotation(field: FieldInfo):
13781378
def should_index_field(field_info: Union[FieldInfo, PydanticFieldInfo]) -> bool:
13791379
# for vector, full text search, and sortable fields, we always have to index
13801380
# We could require the user to set index=True, but that would be a breaking change
1381-
index = getattr(field_info, "index", None) is True
1381+
_index = getattr(field_info, "index", None)
1382+
1383+
index = _index is True
13821384
vector_options = getattr(field_info, "vector_options", None) is not None
13831385
full_text_search = getattr(field_info, "full_text_search", None) is True
13841386
sortable = getattr(field_info, "sortable", None) is True
13851387

1386-
if index is False and any([vector_options, full_text_search, sortable]):
1388+
if _index is False and any([vector_options, full_text_search, sortable]):
13871389
log.warning(
13881390
"Field is marked as index=False, but it is a vector, full text search, or sortable field. "
13891391
"This will be ignored and the field will be indexed.",
@@ -1965,7 +1967,7 @@ def schema_for_type(
19651967
json_path: str,
19661968
name: str,
19671969
name_prefix: str,
1968-
typ: Union[type[RedisModel], Any],
1970+
typ: Union[Type[RedisModel], Any],
19691971
field_info: PydanticFieldInfo,
19701972
parent_type: Optional[Any] = None,
19711973
) -> str:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redis-om"
3-
version = "1.0.0-beta"
3+
version = "1.0.1-beta"
44
description = "Object mappings, and more, for Redis."
55
authors = ["Redis OSS <[email protected]>"]
66
maintainers = ["Redis OSS <[email protected]>"]

tests/test_knn_expression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# type: ignore
22
import abc
33
import struct
4-
from typing import Optional
4+
from typing import Optional, Type
55

66
import pytest_asyncio
77

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

4343

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

0 commit comments

Comments
 (0)