Skip to content

Commit 6af2641

Browse files
committed
ruff check --fix
1 parent ce555a1 commit 6af2641

9 files changed

Lines changed: 25 additions & 31 deletions

src_py/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import warnings
4-
from collections.abc import Callable
54
from typing import TYPE_CHECKING, Any
65

76
from . import _lbug
@@ -10,6 +9,7 @@
109

1110
if TYPE_CHECKING:
1211
import sys
12+
from collections.abc import Callable
1313
from types import TracebackType
1414

1515
from .database import Database

src_py/query_result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def get_schema(self) -> dict[str, str]:
272272
return dict(
273273
zip(
274274
self._query_result.getColumnNames(),
275-
self._query_result.getColumnDataTypes(),
275+
self._query_result.getColumnDataTypes(), strict=False,
276276
)
277277
)
278278

@@ -511,4 +511,4 @@ def _row_to_dict(columns: list[str], row: list[Any]) -> dict[str, Any]:
511511
msg = "Number of columns in output row does not match number of columns"
512512
raise RuntimeError(msg)
513513

514-
return dict(zip(columns, row))
514+
return dict(zip(columns, row, strict=False))

src_py/torch_geometric_graph_store.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@
1111
from .connection import Connection
1212

1313
if TYPE_CHECKING:
14-
import sys
14+
from typing import TypeAlias
1515

1616
from torch_geometric.typing import EdgeTensorType
1717

1818
from .database import Database
1919

20-
if sys.version_info >= (3, 10):
21-
from typing import TypeAlias
22-
else:
23-
from typing import TypeAlias
24-
2520
StoreKeyType: TypeAlias = tuple[tuple[str], Any, bool]
2621

2722
REL_BATCH_SIZE = 1000000

test/test_arrow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def _test_node(_conn: lb.Connection) -> None:
599599
ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[8],
600600
ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[9],
601601
ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[10],
602-
],
602+
], strict=False,
603603
):
604604
_test_node_helper(a, b)
605605

@@ -620,7 +620,7 @@ def _test_node_rel(_conn: lb.Connection) -> None:
620620
ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[3],
621621
ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[5],
622622
ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[7],
623-
],
623+
], strict=False,
624624
):
625625
_test_node_helper(a, b)
626626
for a, b in zip(
@@ -653,7 +653,7 @@ def _test_node_rel(_conn: lb.Connection) -> None:
653653
"rating": 9.2,
654654
"year": 2015,
655655
},
656-
],
656+
], strict=False,
657657
):
658658
_test_node_helper(a, b)
659659

@@ -663,7 +663,7 @@ def _test_node_rel(_conn: lb.Connection) -> None:
663663
ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[4],
664664
ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[6],
665665
ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[6],
666-
],
666+
], strict=False,
667667
):
668668
_test_node_helper(a, b)
669669

@@ -731,7 +731,7 @@ def _test_recursive_rel(_conn: lb.Connection) -> None:
731731
[5, 3, 2],
732732
[5, 3, 5],
733733
]
734-
for row, expected in zip(arrow_tbl["path"], expected_nodes):
734+
for row, expected in zip(arrow_tbl["path"], expected_nodes, strict=False):
735735
cur_ids = []
736736
rel_ids = []
737737
for node in row[NODES]:

test/test_connection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def test_connection_close(tmp_path: Path) -> None:
1818
conn = lb.Connection(db)
1919
conn.close()
2020
assert conn.is_closed
21-
pytest.raises(RuntimeError, conn.execute, "RETURN 1")
21+
with pytest.raises(RuntimeError):
22+
conn.execute("RETURN 1")
2223
db.close()
2324

2425

@@ -28,7 +29,8 @@ def test_connection_close_context_manager(tmp_path: Path) -> None:
2829
with lb.Connection(db) as conn:
2930
pass
3031
assert conn.is_closed
31-
pytest.raises(RuntimeError, conn.execute, "RETURN 1")
32+
with pytest.raises(RuntimeError):
33+
conn.execute("RETURN 1")
3234
assert db.is_closed
3335

3436

test/test_df.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _test_person_to_df(conn: lb.Connection) -> None:
126126
assert str(pd["p.grades"].dtype) == "object"
127127
expected_values = [1.731, 0.99, 1.00, 1.30, 1.463, 1.51, 1.6, 1.323]
128128
actual_values = pd["p.height"].tolist()
129-
for expected, actual in zip(expected_values, actual_values):
129+
for expected, actual in zip(expected_values, actual_values, strict=False):
130130
assert math.isclose(actual, expected, rel_tol=1e-5)
131131
assert str(pd["p.height"].dtype) == "float32"
132132

test/test_scan_pandas_pyarrow.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def generate_primitive_df(scale, names, schema):
3939
return pd.DataFrame(
4040
{
4141
name: generate_primitive_series(scale, dtype)
42-
for name, dtype in zip(names, schema)
42+
for name, dtype in zip(names, schema, strict=False)
4343
}
4444
)
4545

@@ -180,19 +180,19 @@ def test_pyarrow_time(conn_db_readonly: ConnDB) -> None:
180180
)
181181
result = conn.execute("LOAD FROM df RETURN *").get_as_df()
182182
for colname in ["col1", "col2", "col3"]:
183-
for expected, actual in zip(df[colname], result[colname]):
183+
for expected, actual in zip(df[colname], result[colname], strict=False):
184184
tmp1 = (
185185
expected if type(expected) is timedelta else expected.to_pytimedelta()
186186
)
187187
tmp2 = actual if type(actual) is timedelta else actual.to_pytimedelta()
188188
assert tmp1 == tmp2
189189
for colname in ["col4", "col5", "col6", "col7", "col8"]:
190-
for expected, actual in zip(df[colname], result[colname]):
190+
for expected, actual in zip(df[colname], result[colname], strict=False):
191191
tmp1 = expected if type(expected) is datetime else expected.to_pydatetime()
192192
tmp2 = actual if type(actual) is datetime else actual.to_pydatetime()
193193
assert tmp1 == tmp2
194194
for colname in ["col9", "col10"]:
195-
for expected, actual in zip(df[colname], result[colname]):
195+
for expected, actual in zip(df[colname], result[colname], strict=False):
196196
assert (
197197
datetime.combine(expected, datetime.min.time())
198198
== actual.to_pydatetime()
@@ -230,7 +230,7 @@ def test_pyarrow_blob(conn_db_readonly: ConnDB) -> None:
230230
).sort_values(by=["index"])
231231
result = conn.execute("LOAD FROM df RETURN * ORDER BY index").get_as_df()
232232
for colname in ["col1", "col2", "col3", "col4"]:
233-
for expected, actual in zip(df[colname], result[colname]):
233+
for expected, actual in zip(df[colname], result[colname], strict=False):
234234
if is_null(expected) or is_null(actual):
235235
assert is_null(expected)
236236
assert is_null(actual)
@@ -279,7 +279,7 @@ def test_pyarrow_string(conn_db_readonly: ConnDB) -> None:
279279
).sort_values(by=["index"])
280280
result = conn.execute("LOAD FROM df RETURN * ORDER BY index").get_as_df()
281281
for colname in ["col1", "col2", "col3"]:
282-
for expected, actual in zip(df[colname], result[colname]):
282+
for expected, actual in zip(df[colname], result[colname], strict=False):
283283
if is_null(expected) or is_null(actual):
284284
assert is_null(expected)
285285
assert is_null(actual)
@@ -307,7 +307,7 @@ def test_pyarrow_dict(conn_db_readonly: ConnDB) -> None:
307307
)
308308
result = conn.execute("LOAD FROM df RETURN * ORDER BY index").get_as_df()
309309
for colname in ["col1", "col2"]:
310-
for expected, actual in zip(df[colname], result[colname]):
310+
for expected, actual in zip(df[colname], result[colname], strict=False):
311311
assert expected == actual
312312

313313

test/test_udf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ def throw() -> int:
220220

221221
conn.create_function("testexcept", throw)
222222

223-
pytest.raises(RuntimeError, conn.execute, "RETURN testexcept()")
223+
with pytest.raises(RuntimeError):
224+
conn.execute("RETURN testexcept()")
224225

225226
conn.remove_function("testexcept")
226227
conn.create_function("testexcept", throw, catch_exceptions=True)

test/type_aliases.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import sys
21

3-
from real_ladybug import Connection, Database
2+
from typing import TypeAlias
43

5-
if sys.version_info >= (3, 10):
6-
from typing import TypeAlias
7-
else:
8-
from typing import TypeAlias
4+
from real_ladybug import Connection, Database
95

106
ConnDB: TypeAlias = tuple[Connection, Database]

0 commit comments

Comments
 (0)