Skip to content

Commit

Permalink
chore: Enable PERF Ruff rule (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Sep 23, 2024
1 parent ab7a5e8 commit 4df8019
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
25 changes: 13 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,19 @@ target-version = "py38"

[tool.ruff.lint]
select = [
"F", # Pyflakes
"W", # pycodestyle warnings
"E", # pycodestyle errors
"FA", # flake8-future-annotations
"I", # isort
"N", # pep8-naming
"D", # pydocsyle
"UP", # pyupgrade
"ICN", # flake8-import-conventions
"RET", # flake8-return
"SIM", # flake8-simplify
"RUF", # ruff
"F", # Pyflakes
"W", # pycodestyle warnings
"E", # pycodestyle errors
"FA", # flake8-future-annotations
"I", # isort
"N", # pep8-naming
"D", # pydocsyle
"UP", # pyupgrade
"ICN", # flake8-import-conventions
"RET", # flake8-return
"SIM", # flake8-simplify
"PERF", # Perflint
"RUF", # ruff
]

[tool.ruff.lint.flake8-import-conventions]
Expand Down
16 changes: 4 additions & 12 deletions target_postgres/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ def copy_table_structure(
_, schema_name, table_name = self.parse_full_table_name(full_table_name)
meta = sa.MetaData(schema=schema_name)
new_table: sa.Table
columns = []
if self.table_exists(full_table_name=full_table_name):
raise RuntimeError("Table already exists")
for column in from_table.columns:
columns.append(column._copy())

columns = [column._copy() for column in from_table.columns]
if as_temp_table:
new_table = sa.Table(table_name, meta, *columns, prefixes=["TEMPORARY"])
new_table.create(bind=connection)
Expand All @@ -204,14 +203,7 @@ def clone_table(
self, new_table_name, table, metadata, connection, temp_table
) -> sa.Table:
"""Clone a table."""
new_columns = []
for column in table.columns:
new_columns.append(
sa.Column(
column.name,
column.type,
)
)
new_columns = [sa.Column(column.name, column.type) for column in table.columns]
if temp_table is True:
new_table = sa.Table(
new_table_name, metadata, *new_columns, prefixes=["TEMPORARY"]
Expand Down Expand Up @@ -752,7 +744,7 @@ def guess_key_type(self, key_data: str) -> paramiko.PKey:
):
try:
key = key_class.from_private_key(io.StringIO(key_data)) # type: ignore[attr-defined]
except paramiko.SSHException:
except paramiko.SSHException: # noqa: PERF203
continue
else:
return key
Expand Down

0 comments on commit 4df8019

Please sign in to comment.