Apply updated pre-commit hooks.
This commit is contained in:
1 parent
5695a95f81
commit
a856f0d524
5 files changed
+11
-7
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -6,7 +6,6 @@ from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = []
|
||||
|
||||
@@ -6,7 +6,6 @@ from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("app_create_index_exclusive", "0001_initial"),
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user