Apply updated pre-commit hooks.

This commit is contained in:
David Wobrock authored and David Wobrock committed 2023-07-09 14:42:35 +02:00
1 parent 5695a95f81
commit a856f0d524
5 files changed
+11 -7

No files matched your search

-2
View File
@@ -21,8 +21,6 @@ repos:
rev: 6.0.0 rev: 6.0.0
hooks: hooks:
- id: flake8 - id: flake8
args:
- "--max-line-length=88"
exclude: ^tests/ exclude: ^tests/
- repo: https://github.com/pycqa/isort - repo: https://github.com/pycqa/isort
rev: 5.12.0 rev: 5.12.0
@@ -26,16 +26,20 @@ def has_create_index_in_transaction(sql_statements: list[str], **kwargs) -> bool
return False return False
for i, sql in enumerate(sql_statements): 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: # Nearly every single `ALTER TABLE` command requires an exclusive lock:
# https://www.postgresql.org/docs/current/sql-altertable.html # 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"): if sql.startswith("ALTER TABLE"):
return has_create_index(sql_statements[i + 1 :], ignore_concurrently=False) return has_create_index(sql_statements[i + 1 :], ignore_concurrently=False)
return 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 regex_result = None
for sql in sql_statements: for sql in sql_statements:
regex_result = re.search(r"CREATE (UNIQUE )?INDEX.*ON (.*) \(", sql) regex_result = re.search(r"CREATE (UNIQUE )?INDEX.*ON (.*) \(", sql)
+4
View File
@@ -7,3 +7,7 @@ ensure_newline_before_comments = True
line_length = 88 line_length = 88
add_imports = add_imports =
from __future__ import annotations 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): class Migration(migrations.Migration):
initial = True initial = True
dependencies = [] dependencies = []
@@ -6,7 +6,6 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("app_create_index_exclusive", "0001_initial"), ("app_create_index_exclusive", "0001_initial"),
] ]