Skip to content

Commit 4df8019

Browse files
chore: Enable PERF Ruff rule (#443)
1 parent ab7a5e8 commit 4df8019

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

pyproject.toml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,19 @@ target-version = "py38"
8585

8686
[tool.ruff.lint]
8787
select = [
88-
"F", # Pyflakes
89-
"W", # pycodestyle warnings
90-
"E", # pycodestyle errors
91-
"FA", # flake8-future-annotations
92-
"I", # isort
93-
"N", # pep8-naming
94-
"D", # pydocsyle
95-
"UP", # pyupgrade
96-
"ICN", # flake8-import-conventions
97-
"RET", # flake8-return
98-
"SIM", # flake8-simplify
99-
"RUF", # ruff
88+
"F", # Pyflakes
89+
"W", # pycodestyle warnings
90+
"E", # pycodestyle errors
91+
"FA", # flake8-future-annotations
92+
"I", # isort
93+
"N", # pep8-naming
94+
"D", # pydocsyle
95+
"UP", # pyupgrade
96+
"ICN", # flake8-import-conventions
97+
"RET", # flake8-return
98+
"SIM", # flake8-simplify
99+
"PERF", # Perflint
100+
"RUF", # ruff
100101
]
101102

102103
[tool.ruff.lint.flake8-import-conventions]

target_postgres/connector.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,10 @@ def copy_table_structure(
178178
_, schema_name, table_name = self.parse_full_table_name(full_table_name)
179179
meta = sa.MetaData(schema=schema_name)
180180
new_table: sa.Table
181-
columns = []
182181
if self.table_exists(full_table_name=full_table_name):
183182
raise RuntimeError("Table already exists")
184-
for column in from_table.columns:
185-
columns.append(column._copy())
183+
184+
columns = [column._copy() for column in from_table.columns]
186185
if as_temp_table:
187186
new_table = sa.Table(table_name, meta, *columns, prefixes=["TEMPORARY"])
188187
new_table.create(bind=connection)
@@ -204,14 +203,7 @@ def clone_table(
204203
self, new_table_name, table, metadata, connection, temp_table
205204
) -> sa.Table:
206205
"""Clone a table."""
207-
new_columns = []
208-
for column in table.columns:
209-
new_columns.append(
210-
sa.Column(
211-
column.name,
212-
column.type,
213-
)
214-
)
206+
new_columns = [sa.Column(column.name, column.type) for column in table.columns]
215207
if temp_table is True:
216208
new_table = sa.Table(
217209
new_table_name, metadata, *new_columns, prefixes=["TEMPORARY"]
@@ -752,7 +744,7 @@ def guess_key_type(self, key_data: str) -> paramiko.PKey:
752744
):
753745
try:
754746
key = key_class.from_private_key(io.StringIO(key_data)) # type: ignore[attr-defined]
755-
except paramiko.SSHException:
747+
except paramiko.SSHException: # noqa: PERF203
756748
continue
757749
else:
758750
return key

0 commit comments

Comments
 (0)