Skip to content

Commit ffdcea9

Browse files
committed
Fixed CI
1 parent 0c33b6d commit ffdcea9

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎tests/test_sqlalchemy.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pgvector.sqlalchemy import VECTOR, HALFVEC, BIT, SPARSEVEC, avg, sum
55
import pytest
66
from sqlalchemy import create_engine, event, insert, inspect, literal, select, text, MetaData, Table, Column, Index, Integer, ARRAY, Engine
7+
from sqlalchemy.dialects import postgresql
78
from sqlalchemy.exc import StatementError
89
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine, AsyncEngine
910
from sqlalchemy.ext.automap import automap_base
@@ -12,11 +13,7 @@
1213
from typing import Any
1314
from .conftest import numpy as np
1415

15-
try:
16-
from sqlalchemy.dialects.postgresql import BitString
17-
sqlalchemy_version = 2.1
18-
except ImportError:
19-
sqlalchemy_version = 2
16+
sqlalchemy_version = 2.1 if hasattr(postgresql, 'BitString') else 2
2017

2118
psycopg2_engine = create_engine('postgresql+psycopg2://localhost/pgvector_python_test')
2219
psycopg2_type_engine = create_engine('postgresql+psycopg2://localhost/pgvector_python_test')
@@ -642,7 +639,7 @@ async def test_bit(self, engine: AsyncEngine) -> None:
642639
async with session.begin():
643640
embedding: Any
644641
if sqlalchemy_version >= 2.1:
645-
embedding = BitString('101')
642+
embedding = postgresql.BitString('101') # type: ignore
646643
elif engine == asyncpg_engine:
647644
# typing issue
648645
# https://github.com/MagicStack/py-pgproto/pull/32

0 commit comments

Comments
 (0)