Skip to content

Commit 7f13df6

Browse files
committed
style: apply ruff format and import sorting
Run make style to satisfy the ruff format and isort (I) checks so the lint gate passes.
1 parent e52a075 commit 7f13df6

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

tests/migrations/test_schema_editor_sql.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ class Meta:
218218
await editor.add_index(Customer, index)
219219

220220
assert client.executed
221-
expected_name = editor._generate_index_name("uidx", Customer, ["shop_id", "phone_number", "deleted_at"])
221+
expected_name = editor._generate_index_name(
222+
"uidx", Customer, ["shop_id", "phone_number", "deleted_at"]
223+
)
222224
assert (
223225
f'CREATE UNIQUE INDEX "{expected_name}" ON "customer"'
224226
f' ("shop_id", "phone_number", "deleted_at") NULLS NOT DISTINCT;'
@@ -252,7 +254,9 @@ class Meta:
252254
await editor.add_index(Customer, index)
253255

254256
assert client.executed
255-
expected_name = editor._generate_index_name("uidx", Customer, ["shop_id", "phone_number", "deleted_at"])
257+
expected_name = editor._generate_index_name(
258+
"uidx", Customer, ["shop_id", "phone_number", "deleted_at"]
259+
)
256260
assert (
257261
f'CREATE UNIQUE INDEX "{expected_name}" ON "customer"'
258262
f' ("shop_id", "phone_number", "deleted_at") NULLS NOT DISTINCT WHERE shop_id = 1;'

tests/schema/models_postgres_unique_index.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from tortoise import Model, fields
2-
32
from tortoise.contrib.postgres.indexes import PostgreSQLIndex
43

54

tortoise/backends/base_postgres/schema_generator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
class BasePostgresSchemaGenerator(BaseSchemaGenerator):
1515
DIALECT = "postgres"
16-
INDEX_CREATE_TEMPLATE = (
17-
'CREATE INDEX {exists}"{index_name}" ON {table_name} {index_type}({fields}){nulls_not_distinct}{extra};'
18-
)
16+
INDEX_CREATE_TEMPLATE = 'CREATE INDEX {exists}"{index_name}" ON {table_name} {index_type}({fields}){nulls_not_distinct}{extra};'
1917
UNIQUE_INDEX_CREATE_TEMPLATE = INDEX_CREATE_TEMPLATE.replace("INDEX", "UNIQUE INDEX")
2018
TABLE_COMMENT_TEMPLATE = "COMMENT ON TABLE {table} IS '{comment}';"
2119
COLUMN_COMMENT_TEMPLATE = "COMMENT ON COLUMN {table}.\"{column}\" IS '{comment}';"

tortoise/migrations/schema_editor/base_postgres.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
class BasePostgresSchemaEditor(BaseSchemaEditor):
1111
DIALECT = "postgres"
12-
INDEX_CREATE_TEMPLATE = (
13-
'CREATE INDEX "{index_name}" ON {table_name} {index_type}({fields}){nulls_not_distinct}{extra};'
14-
)
12+
INDEX_CREATE_TEMPLATE = 'CREATE INDEX "{index_name}" ON {table_name} {index_type}({fields}){nulls_not_distinct}{extra};'
1513
UNIQUE_INDEX_CREATE_TEMPLATE = INDEX_CREATE_TEMPLATE.replace("INDEX", "UNIQUE INDEX")
1614
TABLE_COMMENT_TEMPLATE = "COMMENT ON TABLE {table} IS '{comment}';"
1715
COLUMN_COMMENT_TEMPLATE = "COMMENT ON COLUMN {table}.\"{column}\" IS '{comment}';"

0 commit comments

Comments
 (0)