Skip to content

Commit e73bac2

Browse files
committed
Added return type annotations to tests [skip ci]
1 parent e0632b8 commit e73bac2

12 files changed

Lines changed: 239 additions & 239 deletions

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ files = [
4646
"tests"
4747
]
4848
strict = true
49-
disable_error_code = ["unused-ignore", "no-untyped-def"]
49+
disable_error_code = ["unused-ignore"]
5050
ignore_missing_imports = true
5151
disallow_subclassing_any = false
5252
python_executable = ".venv/bin/python"

tests/test_asyncpg.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async def setup_connection(self) -> Connection:
1919
return conn
2020

2121
@pytest.mark.asyncio
22-
async def test_vector(self):
22+
async def test_vector(self) -> None:
2323
conn = await self.setup_connection()
2424
await conn.execute('DROP TABLE IF EXISTS asyncpg_items')
2525
await conn.execute('CREATE TABLE asyncpg_items (id bigserial PRIMARY KEY, embedding vector(3))')
@@ -43,7 +43,7 @@ async def test_vector(self):
4343
await conn.close()
4444

4545
@pytest.mark.asyncio
46-
async def test_halfvec(self):
46+
async def test_halfvec(self) -> None:
4747
conn = await self.setup_connection()
4848
await conn.execute('DROP TABLE IF EXISTS asyncpg_items')
4949
await conn.execute('CREATE TABLE asyncpg_items (id bigserial PRIMARY KEY, embedding halfvec(3))')
@@ -65,7 +65,7 @@ async def test_halfvec(self):
6565
await conn.close()
6666

6767
@pytest.mark.asyncio
68-
async def test_bit(self):
68+
async def test_bit(self) -> None:
6969
conn = await self.setup_connection()
7070
await conn.execute('DROP TABLE IF EXISTS asyncpg_items')
7171
await conn.execute('CREATE TABLE asyncpg_items (id bigserial PRIMARY KEY, embedding bit(3))')
@@ -86,7 +86,7 @@ async def test_bit(self):
8686
await conn.close()
8787

8888
@pytest.mark.asyncio
89-
async def test_sparsevec(self):
89+
async def test_sparsevec(self) -> None:
9090
conn = await self.setup_connection()
9191
await conn.execute('DROP TABLE IF EXISTS asyncpg_items')
9292
await conn.execute('CREATE TABLE asyncpg_items (id bigserial PRIMARY KEY, embedding sparsevec(3))')
@@ -106,7 +106,7 @@ async def test_sparsevec(self):
106106
await conn.close()
107107

108108
@pytest.mark.asyncio
109-
async def test_vector_array(self):
109+
async def test_vector_array(self) -> None:
110110
conn = await self.setup_connection()
111111
await conn.execute('DROP TABLE IF EXISTS asyncpg_items')
112112
await conn.execute('CREATE TABLE asyncpg_items (id bigserial PRIMARY KEY, embeddings vector[])')
@@ -130,8 +130,8 @@ async def test_vector_array(self):
130130
await conn.close()
131131

132132
@pytest.mark.asyncio
133-
async def test_pool(self):
134-
async def init(conn):
133+
async def test_pool(self) -> None:
134+
async def init(conn) -> None:
135135
await register_vector(conn)
136136

137137
pool = await asyncpg.create_pool(database='pgvector_python_test', init=init)

tests/test_bit.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,74 +10,74 @@
1010

1111

1212
class TestBit:
13-
def test_list(self):
13+
def test_list(self) -> None:
1414
assert Bit([True, False, True]).to_list() == [True, False, True]
1515

16-
def test_list_none(self):
16+
def test_list_none(self) -> None:
1717
with pytest.raises(ValueError) as error:
1818
Bit([True, None, True]) # type: ignore
1919
assert str(error.value) == 'expected list[bool]'
2020

21-
def test_list_int(self):
21+
def test_list_int(self) -> None:
2222
with pytest.raises(ValueError) as error:
2323
Bit([254, 7, 0]) # type: ignore
2424
assert str(error.value) == 'expected list[bool]'
2525

26-
def test_list_list(self):
26+
def test_list_list(self) -> None:
2727
with pytest.raises(ValueError) as error:
2828
Bit([[True, False], [True, False]]) # type: ignore
2929
assert str(error.value) == 'expected list[bool]'
3030

31-
def test_str(self):
31+
def test_str(self) -> None:
3232
assert Bit('101').to_list() == [True, False, True]
3333

34-
def test_str_two(self):
34+
def test_str_two(self) -> None:
3535
with pytest.raises(ValueError) as error:
3636
Bit('201')
3737
assert str(error.value) == 'expected bit string'
3838

39-
def test_bytes(self):
39+
def test_bytes(self) -> None:
4040
assert Bit(b'\xff\x00\xf0').to_text() == '111111110000000011110000'
4141
assert Bit(b'\xfe\x07\x00').to_text() == '111111100000011100000000'
4242

4343
@pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required')
44-
def test_ndarray(self):
44+
def test_ndarray(self) -> None:
4545
arr = np.array([True, False, True])
4646
assert Bit(arr).to_list() == [True, False, True]
4747
assert np.array_equal(Bit(arr).to_numpy(), arr)
4848

4949
@pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required')
50-
def test_ndarray_unpackbits(self):
50+
def test_ndarray_unpackbits(self) -> None:
5151
arr = np.unpackbits(np.array([254, 7, 0], dtype=np.uint8))
5252
assert Bit(arr).to_text() == '111111100000011100000000'
5353

5454
@pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required')
55-
def test_ndarray_uint8(self):
55+
def test_ndarray_uint8(self) -> None:
5656
arr = np.array([254, 7, 0], dtype=np.uint8)
5757
with pytest.raises(ValueError) as error:
5858
Bit(arr)
5959
assert str(error.value) == 'expected elements to be boolean'
6060

6161
@pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required')
62-
def test_ndarray_uint16(self):
62+
def test_ndarray_uint16(self) -> None:
6363
arr = np.array([254, 7, 0], dtype=np.uint16)
6464
with pytest.raises(ValueError) as error:
6565
Bit(arr) # type: ignore
6666
assert str(error.value) == 'expected elements to be boolean'
6767

68-
def test_bool(self):
68+
def test_bool(self) -> None:
6969
with pytest.raises(ValueError) as error:
7070
Bit(True) # type: ignore
7171
assert str(error.value) == 'expected bytes, str, list, or ndarray'
7272

73-
def test_random(self):
73+
def test_random(self) -> None:
7474
value = ''.join(random.choices(['0', '1'], k=random.randint(1024, 2048)))
7575
assert Bit(value).to_text() == value
7676

77-
def test_repr(self):
77+
def test_repr(self) -> None:
7878
assert repr(Bit([True, False, True])) == 'Bit(101)'
7979
assert str(Bit([True, False, True])) == 'Bit(101)'
8080

81-
def test_equality(self):
81+
def test_equality(self) -> None:
8282
assert Bit([True, False, True]) == Bit([True, False, True])
8383
assert Bit([True, False, True]) != Bit([True, False, False])

tests/test_half_vector.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,58 +10,58 @@
1010

1111

1212
class TestHalfVector:
13-
def test_list(self):
13+
def test_list(self) -> None:
1414
assert HalfVector([1, 2, 3]).to_list() == [1, 2, 3]
1515

16-
def test_list_empty(self):
16+
def test_list_empty(self) -> None:
1717
assert HalfVector([]).to_list() == []
1818

19-
def test_list_str(self):
19+
def test_list_str(self) -> None:
2020
with pytest.raises(ValueError) as error:
2121
HalfVector([1, 'two', 3]) # type: ignore
2222
assert str(error.value) == 'expected list[float]'
2323

24-
def test_list_list(self):
24+
def test_list_list(self) -> None:
2525
with pytest.raises(ValueError) as error:
2626
HalfVector([[1, 2], [3, 4]]) # type: ignore
2727
assert str(error.value) == 'expected list[float]'
2828

2929
@pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required')
30-
def test_ndarray(self):
30+
def test_ndarray(self) -> None:
3131
arr = np.array([1, 2, 3])
3232
assert HalfVector(arr).to_list() == [1, 2, 3]
3333
assert HalfVector(arr).to_numpy() is not arr
3434

35-
def test_int(self):
35+
def test_int(self) -> None:
3636
with pytest.raises(ValueError) as error:
3737
HalfVector(1) # type: ignore
3838
assert str(error.value) == 'expected list or ndarray'
3939

40-
def test_repr(self):
40+
def test_repr(self) -> None:
4141
assert repr(HalfVector([1, 2, 3])) == 'HalfVector([1.0, 2.0, 3.0])'
4242
assert str(HalfVector([1, 2, 3])) == 'HalfVector([1.0, 2.0, 3.0])'
4343

44-
def test_equality(self):
44+
def test_equality(self) -> None:
4545
assert HalfVector([1, 2, 3]) == HalfVector([1, 2, 3])
4646
assert HalfVector([1, 2, 3]) != HalfVector([1, 2, 4])
4747

48-
def test_dimensions(self):
48+
def test_dimensions(self) -> None:
4949
assert HalfVector([1, 2, 3]).dimensions() == 3
5050

5151
@pytest.mark.skipif(not NUMPY_AVAILABLE, reason='NumPy required')
52-
def test_to_numpy_readonly(self):
52+
def test_to_numpy_readonly(self) -> None:
5353
arr = HalfVector([1, 2, 3]).to_numpy()
5454
with pytest.raises(ValueError) as error:
5555
arr[0] = 4
5656
assert str(error.value) == 'assignment destination is read-only'
5757

58-
def test_from_text(self):
58+
def test_from_text(self) -> None:
5959
vec = HalfVector.from_text('[1.5,2,3]')
6060
assert vec.to_list() == [1.5, 2, 3]
6161
if NUMPY_AVAILABLE:
6262
assert np.array_equal(vec.to_numpy(), [1.5, 2, 3])
6363

64-
def test_from_binary(self):
64+
def test_from_binary(self) -> None:
6565
data = pack('>HH3e', 3, 0, 1.5, 2, 3)
6666
vec = HalfVector.from_binary(data)
6767
assert vec.to_list() == [1.5, 2, 3]

0 commit comments

Comments
 (0)