Skip to content

Commit e040dac

Browse files
chore: Enable TCH Ruff rule
1 parent 4df8019 commit e040dac

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ select = [
9696
"ICN", # flake8-import-conventions
9797
"RET", # flake8-return
9898
"SIM", # flake8-simplify
99+
"TCH", # flake8-type-checking
99100
"PERF", # Perflint
100101
"RUF", # ruff
101102
]

target_postgres/connector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def create_empty_table( # type: ignore[override]
375375
376376
Args:
377377
table_name: the target table name.
378-
meta: the SQLAchemy metadata object.
378+
meta: the SQLAlchemy metadata object.
379379
schema: the JSON schema for the new table.
380380
connection: the database connection.
381381
primary_keys: list of key properties.
@@ -574,7 +574,7 @@ def _adapt_column_type( # type: ignore[override]
574574
return
575575

576576
# Not the same type, generic type or compatible types
577-
# calling merge_sql_types for assistnace
577+
# calling merge_sql_types for assistance
578578
compatible_sql_type = self.merge_sql_types([current_type, sql_type])
579579

580580
if str(compatible_sql_type) == str(current_type):

target_postgres/sinks.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
import sqlalchemy as sa
1010
from singer_sdk.sinks import SQLSink
11-
from sqlalchemy.sql import Executable
1211
from sqlalchemy.sql.expression import bindparam
1312

1413
from target_postgres.connector import PostgresConnector
1514

1615
if t.TYPE_CHECKING:
1716
from singer_sdk.connectors.sql import FullyQualifiedName
17+
from sqlalchemy.sql import Executable
1818

1919

2020
class PostgresSink(SQLSink):
@@ -52,10 +52,8 @@ def setup(self) -> None:
5252
This method is called on Sink creation, and creates the required Schema and
5353
Table entities in the target database.
5454
"""
55-
if self.key_properties is None or self.key_properties == []:
56-
self.append_only = True
57-
else:
58-
self.append_only = False
55+
self.append_only = self.key_properties is None or self.key_properties == []
56+
5957
if self.schema_name:
6058
self.connector.prepare_schema(self.schema_name)
6159
with self.connector._connect() as connection, connection.begin():
@@ -165,7 +163,7 @@ def bulk_insert_records( # type: ignore[override]
165163
for column in columns:
166164
insert_record[column.name] = record.get(column.name)
167165
# No need to check for a KeyError here because the SDK already
168-
# guaruntees that all key properties exist in the record.
166+
# guarantees that all key properties exist in the record.
169167
primary_key_value = "".join([str(record[key]) for key in primary_keys])
170168
insert_records[primary_key_value] = insert_record
171169
data_to_insert = list(insert_records.values())
@@ -296,7 +294,7 @@ def schema_name(self) -> str | None:
296294
Returns:
297295
The target schema name.
298296
"""
299-
# Look for a default_target_scheme in the configuraion fle
297+
# Look for a default_target_scheme in the configuration fle
300298
default_target_schema: str = self.config.get("default_target_schema", None)
301299
parts = self.stream_name.split("-")
302300

target_postgres/target.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
from __future__ import annotations
44

5-
from pathlib import PurePath
5+
import typing as t
66

77
from singer_sdk import typing as th
88
from singer_sdk.target_base import SQLTarget
99

1010
from target_postgres.sinks import PostgresSink
1111

12+
if t.TYPE_CHECKING:
13+
from pathlib import PurePath
14+
1215

1316
class TargetPostgres(SQLTarget):
1417
"""Target for Postgres."""

0 commit comments

Comments
 (0)