Skip to content

Commit e2606ad

Browse files
committed
Chore: Format code using Ruff 0.9
1 parent cc3fa8d commit e2606ad

File tree

12 files changed

+31
-38
lines changed

12 files changed

+31
-38
lines changed

src/sqlalchemy_cratedb/compat/api13.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def exec_driver_sql(self, statement, parameters=None, execution_options=None):
7171
"""
7272
if execution_options is not None:
7373
raise ValueError(
74-
"SA13 backward-compatibility: " "`exec_driver_sql` does not support `execution_options`"
74+
"SA13 backward-compatibility: `exec_driver_sql` does not support `execution_options`"
7575
)
7676
args_10style, kwargs_10style = _distill_params_20(parameters)
7777
return self.execute(statement, *args_10style, **kwargs_10style)
@@ -106,7 +106,7 @@ def select_sa14(*columns, **kw) -> Select:
106106
if isinstance(columns, tuple) and isinstance(columns[0], list):
107107
if "whereclause" in kw:
108108
raise ValueError(
109-
"SA13 backward-compatibility: " "`whereclause` is both in kwargs and columns tuple"
109+
"SA13 backward-compatibility: `whereclause` is both in kwargs and columns tuple"
110110
)
111111
columns, whereclause = columns
112112
kw["whereclause"] = whereclause

src/sqlalchemy_cratedb/compat/core20.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# with Crate these terms will supersede the license and you may use the
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121

22-
# ruff: noqa: S101 Use of `assert` detected
22+
# ruff: noqa: S101 # Use of `assert` detected
2323

2424
from typing import Any, Dict, List, MutableMapping, Optional, Tuple, Union
2525

@@ -232,8 +232,7 @@ def _get_crud_params(
232232

233233
if stmt._returning and stmt._return_defaults:
234234
raise exc.CompileError(
235-
"Can't compile statement that includes returning() and "
236-
"return_defaults() simultaneously"
235+
"Can't compile statement that includes returning() and return_defaults() simultaneously"
237236
)
238237

239238
if compile_state.isdelete:

src/sqlalchemy_cratedb/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def get_column_specification(self, column, **kwargs):
146146
def visit_computed_column(self, generated):
147147
if generated.persisted is False:
148148
raise sa.exc.CompileError(
149-
"Virtual computed columns are not supported, set " "'persisted' to None or True"
149+
"Virtual computed columns are not supported, set 'persisted' to None or True"
150150
)
151151

152152
return "GENERATED ALWAYS AS (%s)" % self.sql_compiler.process(

src/sqlalchemy_cratedb/dialect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def has_table(self, connection, table_name, schema=None, **kw):
291291
@reflection.cache
292292
def get_schema_names(self, connection, **kw):
293293
cursor = connection.exec_driver_sql(
294-
"select schema_name " "from information_schema.schemata " "order by schema_name asc"
294+
"select schema_name from information_schema.schemata order by schema_name asc"
295295
)
296296
return [row[0] for row in cursor.fetchall()]
297297

src/sqlalchemy_cratedb/type/array.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# with Crate these terms will supersede the license and you may use the
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121

22+
# ruff: noqa: A005 # Module `array` shadows a Python standard-library module
23+
2224
import sqlalchemy.types as sqltypes
2325
from sqlalchemy.ext.mutable import Mutable
2426
from sqlalchemy.sql import default_comparator, expression, operators

tests/array_test.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ def test_create_with_array(self):
6868
)
6969
t1.create(self.engine)
7070
fake_cursor.execute.assert_called_with(
71-
(
72-
"\nCREATE TABLE t (\n\t"
73-
"int_array ARRAY(INT), \n\t"
74-
"str_array ARRAY(STRING)\n)\n\n"
75-
),
71+
("\nCREATE TABLE t (\n\tint_array ARRAY(INT), \n\tstr_array ARRAY(STRING)\n)\n\n"),
7672
(),
7773
)
7874

@@ -88,16 +84,14 @@ def test_array_insert(self):
8884
def test_any(self):
8985
s = self.session.query(self.User.name).filter(self.User.friends.any("arthur"))
9086
self.assertSQL(
91-
"SELECT users.name AS users_name FROM users " "WHERE ? = ANY (users.friends)", s
87+
"SELECT users.name AS users_name FROM users WHERE ? = ANY (users.friends)", s
9288
)
9389

9490
def test_any_with_operator(self):
9591
s = self.session.query(self.User.name).filter(
9692
self.User.scores.any(6, operator=operators.lt)
9793
)
98-
self.assertSQL(
99-
"SELECT users.name AS users_name FROM users " "WHERE ? < ANY (users.scores)", s
100-
)
94+
self.assertSQL("SELECT users.name AS users_name FROM users WHERE ? < ANY (users.scores)", s)
10195

10296
def test_multidimensional_arrays(self):
10397
t1 = sa.Table(

tests/dict_test.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ def test_partial_dict_update(self):
177177
# first isn't deterministic
178178
try:
179179
fake_cursor.execute.assert_called_with(
180-
("UPDATE characters SET data['y'] = ?, data['x'] = ? " "WHERE characters.name = ?"),
180+
("UPDATE characters SET data['y'] = ?, data['x'] = ? WHERE characters.name = ?"),
181181
(2, 1, "Trillian"),
182182
)
183183
except AssertionError:
184184
fake_cursor.execute.assert_called_with(
185-
("UPDATE characters SET data['x'] = ?, data['y'] = ? " "WHERE characters.name = ?"),
185+
("UPDATE characters SET data['x'] = ?, data['y'] = ? WHERE characters.name = ?"),
186186
(1, 2, "Trillian"),
187187
)
188188

@@ -204,7 +204,7 @@ def test_partial_dict_update_only_one_key_changed(self):
204204
char.data["y"] = 3
205205
session.commit()
206206
fake_cursor.execute.assert_called_with(
207-
("UPDATE characters SET data['y'] = ? " "WHERE characters.name = ?"), (3, "Trillian")
207+
("UPDATE characters SET data['y'] = ? WHERE characters.name = ?"), (3, "Trillian")
208208
)
209209

210210
@patch("crate.client.connection.Cursor", FakeCursor)
@@ -218,7 +218,7 @@ def test_partial_dict_update_with_regular_column(self):
218218
char.age = 20
219219
session.commit()
220220
fake_cursor.execute.assert_called_with(
221-
("UPDATE characters SET age = ?, data['x'] = ? " "WHERE characters.name = ?"),
221+
("UPDATE characters SET age = ?, data['x'] = ? WHERE characters.name = ?"),
222222
(20, 1, "Trillian"),
223223
)
224224

@@ -234,7 +234,7 @@ def test_partial_dict_update_with_delitem(self):
234234
self.assertIn(char, session.dirty)
235235
session.commit()
236236
fake_cursor.execute.assert_called_with(
237-
("UPDATE characters SET data['x'] = ? " "WHERE characters.name = ?"), (None, "Trillian")
237+
("UPDATE characters SET data['x'] = ? WHERE characters.name = ?"), (None, "Trillian")
238238
)
239239

240240
@patch("crate.client.connection.Cursor", FakeCursor)
@@ -255,7 +255,7 @@ def test_partial_dict_update_with_delitem_setitem(self):
255255
self.assertIn(char, session.dirty)
256256
session.commit()
257257
fake_cursor.execute.assert_called_with(
258-
("UPDATE characters SET data['x'] = ? " "WHERE characters.name = ?"), (4, "Trillian")
258+
("UPDATE characters SET data['x'] = ? WHERE characters.name = ?"), (4, "Trillian")
259259
)
260260

261261
@patch("crate.client.connection.Cursor", FakeCursor)
@@ -275,7 +275,7 @@ def test_partial_dict_update_with_setitem_delitem(self):
275275
self.assertIn(char, session.dirty)
276276
session.commit()
277277
fake_cursor.execute.assert_called_with(
278-
("UPDATE characters SET data['x'] = ? " "WHERE characters.name = ?"), (None, "Trillian")
278+
("UPDATE characters SET data['x'] = ? WHERE characters.name = ?"), (None, "Trillian")
279279
)
280280

281281
@patch("crate.client.connection.Cursor", FakeCursor)
@@ -296,7 +296,7 @@ def test_partial_dict_update_with_setitem_delitem_setitem(self):
296296
self.assertIn(char, session.dirty)
297297
session.commit()
298298
fake_cursor.execute.assert_called_with(
299-
("UPDATE characters SET data['x'] = ? " "WHERE characters.name = ?"), (3, "Trillian")
299+
("UPDATE characters SET data['x'] = ? WHERE characters.name = ?"), (3, "Trillian")
300300
)
301301

302302
def set_up_character_and_cursor_data_list(self, return_value=None):
@@ -333,7 +333,7 @@ def test_object_array_setitem_change_tracking(self):
333333
self.assertIn(char, session.dirty)
334334
session.commit()
335335
fake_cursor.execute.assert_called_with(
336-
("UPDATE characters SET data_list = ? " "WHERE characters.name = ?"),
336+
("UPDATE characters SET data_list = ? WHERE characters.name = ?"),
337337
([{"1": 1}, {"3": 3}], "Trillian"),
338338
)
339339

@@ -354,7 +354,7 @@ def test_nested_object_change_tracking(self):
354354
self.assertIn(char, session.dirty)
355355
session.commit()
356356
fake_cursor.execute.assert_called_with(
357-
("UPDATE characters SET data['nested'] = ? " "WHERE characters.name = ?"),
357+
("UPDATE characters SET data['nested'] = ? WHERE characters.name = ?"),
358358
({"y": {"z": 2}, "x": 3}, "Trillian"),
359359
)
360360

@@ -366,7 +366,7 @@ def test_deep_nested_object_change_tracking(self):
366366
self.assertIn(char, session.dirty)
367367
session.commit()
368368
fake_cursor.execute.assert_called_with(
369-
("UPDATE characters SET data['nested'] = ? " "WHERE characters.name = ?"),
369+
("UPDATE characters SET data['nested'] = ? WHERE characters.name = ?"),
370370
({"y": {"z": 5}, "x": 1}, "Trillian"),
371371
)
372372

@@ -378,7 +378,7 @@ def test_delete_nested_object_tracking(self):
378378
self.assertIn(char, session.dirty)
379379
session.commit()
380380
fake_cursor.execute.assert_called_with(
381-
("UPDATE characters SET data['nested'] = ? " "WHERE characters.name = ?"),
381+
("UPDATE characters SET data['nested'] = ? WHERE characters.name = ?"),
382382
({"y": {}, "x": 1}, "Trillian"),
383383
)
384384

tests/integration.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ def provision_database():
5858
with open(docs_path("tests/assets/locations.sql")) as s:
5959
stmt = s.read()
6060
cursor.execute(stmt)
61-
stmt = (
62-
"SELECT COUNT(*) FROM information_schema.tables " "WHERE table_name = 'locations'"
63-
)
61+
stmt = "SELECT COUNT(*) FROM information_schema.tables WHERE table_name = 'locations'"
6462
cursor.execute(stmt)
6563
assert cursor.fetchall()[0][0] == 1
6664

tests/test_support_polyfill.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ class FooBar(Base):
143143
result = query.first()
144144

145145
# Sanity checks.
146-
assert (
147-
result is not None
148-
), "Database result is empty. Most probably, `REFRESH TABLE` wasn't issued."
146+
assert result is not None, (
147+
"Database result is empty. Most probably, `REFRESH TABLE` wasn't issued."
148+
)
149149

150150
# Compare outcome.
151151
assert result[0] == "foo"

tests/update_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_onupdate_is_triggered(self):
7474
char.age = 40
7575
self.session.commit()
7676

77-
expected_stmt = "UPDATE characters SET age = ?, " "ts = ? WHERE characters.name = ?"
77+
expected_stmt = "UPDATE characters SET age = ?, ts = ? WHERE characters.name = ?"
7878
args, kwargs = fake_cursor.execute.call_args
7979
stmt = args[0]
8080
args = args[1]
@@ -103,7 +103,7 @@ def test_bulk_update(self):
103103

104104
self.session.commit()
105105

106-
expected_stmt = "UPDATE characters SET " "name = ?, obj = ?, ts = ?"
106+
expected_stmt = "UPDATE characters SET name = ?, obj = ?, ts = ?"
107107
args, kwargs = fake_cursor.execute.call_args
108108
stmt = args[0]
109109
args = args[1]

0 commit comments

Comments
 (0)