File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from psycopg .adapt import Loader , Dumper
44from psycopg .pq import Format
55from psycopg .types import TypeInfo
6- from typing import Any , TypeAlias
6+ from typing import Any , TypeAlias , TYPE_CHECKING
77from .. import Vector
88
99Buffer : TypeAlias = bytes | bytearray | memoryview
1010
11+ if TYPE_CHECKING :
12+ import numpy as np
13+
1114
1215class VectorDumper (Dumper ):
1316 format = Format .TEXT
1417
15- def dump (self , obj : Vector ) -> Buffer | None :
18+ def dump (self , obj : Vector | np . ndarray ) -> Buffer | None :
1619 value = Vector ._to_db (obj )
1720 return value if value is None else value .encode ('utf8' )
1821
1922
2023class VectorBinaryDumper (VectorDumper ):
2124 format = Format .BINARY
2225
23- def dump (self , obj : Vector ) -> Buffer | None :
26+ def dump (self , obj : Vector | np . ndarray ) -> Buffer | None :
2427 return Vector ._to_db_binary (obj )
2528
2629
You can’t perform that action at this time.
0 commit comments