diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 633dbf4..518d8a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,8 +21,6 @@ repos: rev: 6.0.0 hooks: - id: flake8 - args: - - "--max-line-length=88" exclude: ^tests/ - repo: https://github.com/pycqa/isort rev: 5.12.0 diff --git a/django_migration_linter/sql_analyser/postgresql.py b/django_migration_linter/sql_analyser/postgresql.py index cbaec23..28e0624 100644 --- a/django_migration_linter/sql_analyser/postgresql.py +++ b/django_migration_linter/sql_analyser/postgresql.py @@ -26,16 +26,20 @@ def has_create_index_in_transaction(sql_statements: list[str], **kwargs) -> bool return False for i, sql in enumerate(sql_statements): - # If any statements acquire an exclusive lock, complain about index creation later. + # If any statements acquire an exclusive lock, complain about index creation + # later. # Nearly every single `ALTER TABLE` command requires an exclusive lock: # https://www.postgresql.org/docs/current/sql-altertable.html - # (Most common example is `ALTER TABLE... ADD COLUMN`, then later `CREATE INDEX`) + # (Most common example is `ALTER TABLE... ADD COLUMN`, then later + # `CREATE INDEX`) if sql.startswith("ALTER TABLE"): return has_create_index(sql_statements[i + 1 :], ignore_concurrently=False) return False -def has_create_index(sql_statements: list[str], ignore_concurrently: bool = True, **kwargs) -> bool: +def has_create_index( + sql_statements: list[str], ignore_concurrently: bool = True, **kwargs +) -> bool: regex_result = None for sql in sql_statements: regex_result = re.search(r"CREATE (UNIQUE )?INDEX.*ON (.*) \(", sql) diff --git a/setup.cfg b/setup.cfg index 8618a40..9efcc1d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,3 +7,7 @@ ensure_newline_before_comments = True line_length = 88 add_imports = from __future__ import annotations + +[flake8] +max-line-length=88 +ignore=E203,W503 diff --git a/tests/test_project/app_create_index_exclusive/migrations/0001_initial.py b/tests/test_project/app_create_index_exclusive/migrations/0001_initial.py index 2d0e94c..8d2a09f 100644 --- a/tests/test_project/app_create_index_exclusive/migrations/0001_initial.py +++ b/tests/test_project/app_create_index_exclusive/migrations/0001_initial.py @@ -6,7 +6,6 @@ from django.db import migrations, models class Migration(migrations.Migration): - initial = True dependencies = [] diff --git a/tests/test_project/app_create_index_exclusive/migrations/0002_user_email.py b/tests/test_project/app_create_index_exclusive/migrations/0002_user_email.py index b245727..1a17bc5 100644 --- a/tests/test_project/app_create_index_exclusive/migrations/0002_user_email.py +++ b/tests/test_project/app_create_index_exclusive/migrations/0002_user_email.py @@ -6,7 +6,6 @@ from django.db import migrations, models class Migration(migrations.Migration): - dependencies = [ ("app_create_index_exclusive", "0001_initial"), ]