Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#29)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/PyCQA/autoflake: v2.2.1 → v2.3.1](PyCQA/autoflake@v2.2.1...v2.3.1)
- [github.com/psf/black: 23.12.1 → 24.3.0](psf/black@23.12.1...24.3.0)
- [github.com/asottile/pyupgrade: v3.15.0 → v3.15.2](asottile/pyupgrade@v3.15.0...v3.15.2)
- [github.com/pycqa/flake8: 6.1.0 → 7.0.0](PyCQA/flake8@6.1.0...7.0.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Apr 9, 2024
1 parent a5c7b8d commit ae5fdb4
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 65 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:

# Remove unused imports/variables
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
rev: v2.3.1
hooks:
- id: autoflake
args:
Expand All @@ -32,21 +32,21 @@ repos:

# Black formatting
- repo: https://github.com/psf/black
rev: "23.12.1"
rev: "24.3.0"
hooks:
- id: black
args: ["--line-length=99"]

# tool to automatically upgrade syntax for newer versions of the language
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py39-plus]

# Lint files
- repo: https://github.com/pycqa/flake8
rev: "6.1.0"
rev: "7.0.0"
hooks:
- id: flake8
args: [
Expand Down
128 changes: 67 additions & 61 deletions pirogue/multiple_inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,16 @@ def __insert_trigger(self) -> str:
for alias, table_def in sorted_joins
]
),
raise_notice="NULL;"
if self.allow_parent_only
else "RAISE NOTICE '{vn} type not known ({percent_char})', NEW.{type_name}; -- ERROR".format(
vn=self.view_name,
percent_char="%%"
if self.variables
else "%", # if variables, % should be escaped because cursor.execute is run with variables
type_name=self.type_name,
raise_notice=(
"NULL;"
if self.allow_parent_only
else "RAISE NOTICE '{vn} type not known ({percent_char})', NEW.{type_name}; -- ERROR".format(
vn=self.view_name,
percent_char=(
"%%" if self.variables else "%"
), # if variables, % should be escaped because cursor.execute is run with variables
type_name=self.type_name,
)
),
insert_trigger_post=self.insert_trigger.get("post", ""),
)
Expand Down Expand Up @@ -508,51 +510,53 @@ def __update_trigger(self):
indent=8,
),
type_name=self.type_name,
type_change="RAISE EXCEPTION 'Type change not allowed for {alias}'"
"\n USING HINT = 'You cannot switch from ' "
"|| OLD.{type_name} || ' to ' || NEW.{type_name};".format(
alias=self.view_alias, type_name=self.type_name
)
if not self.allow_type_change
else "CASE"
"\n {deletes}"
"\n END CASE;"
"\n CASE"
"\n {inserts}"
"\n ELSE -- do nothing"
"\n END CASE;".format(
deletes="\n ".join(
[
"WHEN OLD.{type_name} = '{alias}'::{vs}.{type_name} "
"THEN DELETE FROM {ts}.{tn} "
"WHERE {rmk} = OLD.{mpk};".format(
type_name=self.type_name,
alias=alias,
vs=self.view_schema,
ts=table_def["table_schema"],
tn=table_def["table_name"],
rmk=table_def["ref_master_key"],
mpk=self.master_pkey,
)
for alias, table_def in sorted_joins
]
),
inserts="\n ".join(
[
"WHEN NEW.{type_name} = '{alias}'::{vs}.{type_name} "
"THEN INSERT INTO {ts}.{tn} "
"({rmk}) VALUES (OLD.{mpk});".format(
type_name=self.type_name,
alias=alias,
vs=self.view_schema,
ts=table_def["table_schema"],
tn=table_def["table_name"],
rmk=table_def["ref_master_key"],
mpk=self.master_pkey,
)
for alias, table_def in sorted_joins
]
),
type_change=(
"RAISE EXCEPTION 'Type change not allowed for {alias}'"
"\n USING HINT = 'You cannot switch from ' "
"|| OLD.{type_name} || ' to ' || NEW.{type_name};".format(
alias=self.view_alias, type_name=self.type_name
)
if not self.allow_type_change
else "CASE"
"\n {deletes}"
"\n END CASE;"
"\n CASE"
"\n {inserts}"
"\n ELSE -- do nothing"
"\n END CASE;".format(
deletes="\n ".join(
[
"WHEN OLD.{type_name} = '{alias}'::{vs}.{type_name} "
"THEN DELETE FROM {ts}.{tn} "
"WHERE {rmk} = OLD.{mpk};".format(
type_name=self.type_name,
alias=alias,
vs=self.view_schema,
ts=table_def["table_schema"],
tn=table_def["table_name"],
rmk=table_def["ref_master_key"],
mpk=self.master_pkey,
)
for alias, table_def in sorted_joins
]
),
inserts="\n ".join(
[
"WHEN NEW.{type_name} = '{alias}'::{vs}.{type_name} "
"THEN INSERT INTO {ts}.{tn} "
"({rmk}) VALUES (OLD.{mpk});".format(
type_name=self.type_name,
alias=alias,
vs=self.view_schema,
ts=table_def["table_schema"],
tn=table_def["table_name"],
rmk=table_def["ref_master_key"],
mpk=self.master_pkey,
)
for alias, table_def in sorted_joins
]
),
)
),
update_joins="\n ".join(
[
Expand Down Expand Up @@ -580,14 +584,16 @@ def __update_trigger(self):
for alias, table_def in sorted_joins
]
),
raise_notice="NULL;"
if self.allow_parent_only
else "RAISE NOTICE '{vn} type not known ({percent_char})', NEW.{type_name}; -- ERROR".format(
vn=self.view_name,
percent_char="%%"
if self.variables
else "%", # if variables, % should be escaped because cursor.execute is run with variables
type_name=self.type_name,
raise_notice=(
"NULL;"
if self.allow_parent_only
else "RAISE NOTICE '{vn} type not known ({percent_char})', NEW.{type_name}; -- ERROR".format(
vn=self.view_name,
percent_char=(
"%%" if self.variables else "%"
), # if variables, % should be escaped because cursor.execute is run with variables
type_name=self.type_name,
)
),
update_trigger_post=self.update_trigger.get("post", ""),
)
Expand Down

0 comments on commit ae5fdb4

Please sign in to comment.