Skip to content

Commit

Permalink
Vector: Fix type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Dec 21, 2023
1 parent 82a9734 commit 264f370
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/sqlalchemy_cratedb/type/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ class ObjectTypeImpl(sqltypes.UserDefinedType, sqltypes.JSON):
none_as_null = False


ObjectType = MutableDict.as_mutable(ObjectTypeImpl)


# Designated name to refer to. `Object` is too ambiguous.
ObjectType = MutableDict.as_mutable(ObjectTypeImpl)

# Backward-compatibility aliases.
_deprecated_Craty = ObjectType
Expand All @@ -89,3 +87,6 @@ def __getattr__(name):
f"Please use ObjectType instead.", DeprecationWarning)
return globals()[f"_deprecated_{name}"]
raise AttributeError(f"module {__name__} has no attribute {name}")


__all__ = deprecated_names
6 changes: 3 additions & 3 deletions src/sqlalchemy_cratedb/type/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
__all__ = ["FloatVector"]


def from_db(value: t.Iterable) -> t.Optional[npt.ArrayLike]:
def from_db(value: t.Iterable) -> t.Optional["npt.ArrayLike"]:
import numpy as np

# from `pgvector.utils`
Expand Down Expand Up @@ -146,13 +146,13 @@ def __init__(self, dimensions: int = None):
def as_generic(self):
return sa.ARRAY

def bind_processor(self, dialect: sa.Dialect) -> t.Callable:
def bind_processor(self, dialect: sa.engine.Dialect) -> t.Callable:
def process(value: t.Iterable) -> t.Optional[t.List]:
return to_db(value, self.dimensions)

return process

def result_processor(self, dialect: sa.Dialect, coltype: t.Any) -> t.Callable:
def result_processor(self, dialect: sa.engine.Dialect, coltype: t.Any) -> t.Callable:
def process(value: t.Any) -> t.Optional[npt.ArrayLike]:
return from_db(value)

Expand Down

0 comments on commit 264f370

Please sign in to comment.