Run black.

This commit is contained in:
David Wobrock authored and David Wobrock committed 2022-11-03 22:00:00 +01:00
1 parent a9405eaf83
commit e8f83708b0
4 files changed
+6 -12

No files matched your search

+3 -5
View File
@@ -301,9 +301,7 @@ class MigrationLinter:
return self.nb_erroneous > 0 return self.nb_erroneous > 0
def get_sql(self, app_label, migration_name): def get_sql(self, app_label, migration_name):
logger.info( logger.info(f"Calling sqlmigrate command {app_label} {migration_name}")
f"Calling sqlmigrate command {app_label} {migration_name}"
)
dev_null = open(os.devnull, "w") dev_null = open(os.devnull, "w")
try: try:
sql_statement = call_command( sql_statement = call_command(
@@ -327,7 +325,7 @@ class MigrationLinter:
from django.db.migrations.loader import MIGRATIONS_MODULE_NAME from django.db.migrations.loader import MIGRATIONS_MODULE_NAME
return ( return (
re.search(fr"/{MIGRATIONS_MODULE_NAME}/.*\.py", filename) re.search(rf"/{MIGRATIONS_MODULE_NAME}/.*\.py", filename)
and "__init__" not in filename and "__init__" not in filename
) )
@@ -537,7 +535,7 @@ class MigrationLinter:
model = model.split(".", 1)[0] model = model.split(".", 1)[0]
has_get_model_call = ( has_get_model_call = (
re.search( re.search(
fr"{model}.*= +\w+\.get_model\(", rf"{model}.*= +\w+\.get_model\(",
source_code, source_code,
) )
is not None is not None
+1 -2
View File
@@ -36,8 +36,7 @@ def has_add_unique(sql_statements, **kwargs):
concerned_table = regex_result.group(1) concerned_table = regex_result.group(1)
table_is_added_in_transaction = any( table_is_added_in_transaction = any(
sql.startswith(f"CREATE TABLE {concerned_table}") sql.startswith(f"CREATE TABLE {concerned_table}") for sql in sql_statements
for sql in sql_statements
) )
return not table_is_added_in_transaction return not table_is_added_in_transaction
@@ -16,8 +16,7 @@ def has_create_index(sql_statements, **kwargs):
concerned_table = regex_result.group(2) concerned_table = regex_result.group(2)
table_is_added_in_transaction = any( table_is_added_in_transaction = any(
sql.startswith(f"CREATE TABLE {concerned_table}") sql.startswith(f"CREATE TABLE {concerned_table}") for sql in sql_statements
for sql in sql_statements
) )
return not table_is_added_in_transaction return not table_is_added_in_transaction
+1 -3
View File
@@ -21,9 +21,7 @@ class SqlAnalyserTestCase(unittest.TestCase):
errors, _, warnings = self.analyse_sql(sql) errors, _, warnings = self.analyse_sql(sql)
self.assertEqual(0, len(errors), f"Found errors in sql: {errors}") self.assertEqual(0, len(errors), f"Found errors in sql: {errors}")
if not allow_warnings: if not allow_warnings:
self.assertEqual( self.assertEqual(0, len(warnings), f"Found warnings in sql: {errors}")
0, len(warnings), f"Found warnings in sql: {errors}"
)
def assertBackwardIncompatibleSql(self, sql, code=None): def assertBackwardIncompatibleSql(self, sql, code=None):
errors, _, _ = self.analyse_sql(sql) errors, _, _ = self.analyse_sql(sql)