Skip to content

Commit 5fd7d42

Browse files
committed
Fix line length issues for static analysis compliance
1 parent 5e9d528 commit 5fd7d42

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

tortoise/backends/base/schema_generator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class BaseSchemaGenerator:
2828
"CREATE TABLE {exists}{table_name} ({fields}){extra}{comment};"
2929
)
3030
FIELD_TEMPLATE = '"{name}" {type}{nullable}{unique}{primary}{default}{comment}'
31-
INDEX_CREATE_TEMPLATE = 'CREATE {index_type}INDEX {exists}"{index_name}" ON {table_name} ({fields}){extra};'
31+
INDEX_CREATE_TEMPLATE = (
32+
'CREATE {index_type}INDEX {exists}"{index_name}" ON {table_name} ({fields}){extra};'
33+
)
3234
UNIQUE_INDEX_CREATE_TEMPLATE = INDEX_CREATE_TEMPLATE.replace(
3335
"INDEX", "UNIQUE INDEX"
3436
)
@@ -180,7 +182,8 @@ def _get_index_name(
180182
def _get_fk_name(
181183
self, from_table: str, from_field: str, to_table: str, to_field: str
182184
) -> str:
183-
# NOTE: for compatibility, index name should not be longer than 30 characters (Oracle limit).
185+
# NOTE: for compatibility, index name should not be longer than 30 characters
186+
# (Oracle limit).
184187
# That's why we slice some of the strings here.
185188
hashed = self._make_hash(from_table, from_field, to_table, to_field, length=8)
186189
return f"fk_{from_table[:8]}_{to_table[:8]}_{hashed}"

tortoise/backends/base_postgres/schema_generator.py

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

1414
class BasePostgresSchemaGenerator(BaseSchemaGenerator):
1515
DIALECT = "postgres"
16-
INDEX_CREATE_TEMPLATE = 'CREATE INDEX {exists}"{index_name}" ON {table_name} {index_type}({fields}){extra};'
16+
INDEX_CREATE_TEMPLATE = (
17+
'CREATE INDEX {exists}"{index_name}" ON {table_name} {index_type}({fields}){extra};'
18+
)
1719
UNIQUE_INDEX_CREATE_TEMPLATE = INDEX_CREATE_TEMPLATE.replace(
1820
"INDEX", "UNIQUE INDEX"
1921
)

0 commit comments

Comments
 (0)