Skip to content

Commit

Permalink
fix static typing
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmith023 committed Jan 30, 2024
1 parent 01ffc5d commit 73c68ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
10 changes: 1 addition & 9 deletions weaviate/collections/classes/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,16 +581,13 @@ def from_input(
GenerativeGroupByReturnType[Properties, References, TProperties, TReferences],
]

QueryReturnWithoutVectors = Union[
QueryReturnType = Union[
QueryReturn[Properties, References, None],
QueryReturn[TProperties, TReferences, None],
QueryReturn[Properties, CrossReferences, None],
QueryReturn[Properties, TReferences, None],
QueryReturn[TProperties, References, None],
QueryReturn[TProperties, CrossReferences, None],
]

QueryReturnWithVectors = Union[
QueryReturn[Properties, References, Vectors],
QueryReturn[TProperties, TReferences, Vectors],
QueryReturn[Properties, CrossReferences, Vectors],
Expand All @@ -599,11 +596,6 @@ def from_input(
QueryReturn[TProperties, CrossReferences, Vectors],
]

QueryReturnType = Union[
QueryReturnWithoutVectors[Properties, References, TProperties, TReferences],
QueryReturnWithVectors[Properties, References, TProperties, TReferences],
]

GroupByReturnType = Union[
GroupByReturn[Properties, References, None],
GroupByReturn[Properties, References, Vectors],
Expand Down
6 changes: 3 additions & 3 deletions weaviate/collections/classes/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@ class _PhoneNumber(_PhoneNumberBase):
M = TypeVar("M")
"""`M` is a completely general type that is used wherever generic metadata objects are defined that can be used"""

V = TypeVar("V")
V = TypeVar("V", covariant=True)
"""`V` is a completely general type that is used wherever generic vector objects are defined that can be used"""

P = TypeVar("P")
P = TypeVar("P", covariant=True)
"""`P` is a completely general type that is used wherever generic properties objects are defined that can be used
within the non-ORM and ORM APIs interchangeably"""

QP = TypeVar("QP")
"""`QP` is a completely general type that is used wherever generic properties objects are defined that can be used
within the non-ORM and ORM APIs interchangeably"""

R = TypeVar("R")
R = TypeVar("R", covariant=True)
"""`R` is a completely general type that is used wherever generic reference objects are defined that can be used
within the non-ORM and ORM APIs interchangeably"""

Expand Down
2 changes: 1 addition & 1 deletion weaviate/collections/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ def iterator(
def iterator(
self,
*,
include_vector: bool = False,
return_metadata: Optional[METADATA] = None,
include_vector: bool = False,
return_properties: Optional[ReturnProperties[TProperties]] = None,
return_references: Optional[ReturnReferences[TReferences]] = None,
) -> ObjectIterator[Properties, References, TProperties, TReferences]:
Expand Down
12 changes: 6 additions & 6 deletions weaviate/collections/queries/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def __result_to_generative_object(
props: search_get_pb2.PropertiesResult,
meta: search_get_pb2.MetadataResult,
options: _QueryOptions,
) -> GenerativeObject[Any, Any, Optional[Vectors]]:
) -> GenerativeObject[Any, Any, Any]:
return GenerativeObject(
collection=props.target_collection,
properties=(
Expand All @@ -283,7 +283,7 @@ def __result_to_group(
self,
res: search_get_pb2.GroupByResult,
options: _QueryOptions,
) -> Group[Any, Any, Optional[Vectors]]:
) -> Group[Any, Any, Any]:
return Group(
objects=[
self.__result_to_group_by_object(obj.properties, obj.metadata, options)
Expand All @@ -300,7 +300,7 @@ def __result_to_generative_group(
self,
res: search_get_pb2.GroupByResult,
options: _QueryOptions,
) -> GenerativeGroup[Any, Any, Optional[Vectors]]:
) -> GenerativeGroup[Any, Any, Any]:
return GenerativeGroup(
objects=[
self.__result_to_group_by_object(obj.properties, obj.metadata, options)
Expand All @@ -319,7 +319,7 @@ def __result_to_group_by_object(
props: search_get_pb2.PropertiesResult,
meta: search_get_pb2.MetadataResult,
options: _QueryOptions,
) -> GroupedObject[Any, Any, Optional[Vectors]]:
) -> GroupedObject[Any, Any, Any]:
return GroupedObject(
collection=props.target_collection,
properties=(
Expand Down Expand Up @@ -350,7 +350,7 @@ def _result_to_query_return(
ReturnReferences[TReferences]
], # required until 3.12 is minimum supported version to use new generics syntax
) -> QueryReturnType[Properties, References, TProperties, TReferences]:
return QueryReturn( # type: ignore # used internally so types not important
return QueryReturn( # type: ignore
objects=[
self.__result_to_query_object(obj.properties, obj.metadata, options)
for obj in res.results
Expand All @@ -368,7 +368,7 @@ def _result_to_generative_query_return(
ReturnReferences[TReferences]
], # required until 3.12 is minimum supported version to use new generics syntax
) -> GenerativeReturnType[Properties, References, TProperties, TReferences]:
return GenerativeReturn( # type: ignore # used internally so types not important
return GenerativeReturn(
objects=[
self.__result_to_generative_object(obj.properties, obj.metadata, options)
for obj in res.results
Expand Down

0 comments on commit 73c68ad

Please sign in to comment.