Skip to content

Commit

Permalink
Ruff fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BTheunissen committed May 15, 2024
1 parent e34b4d2 commit 0b284e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions target_clickhouse/connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_sqlalchemy_url(self, config: dict) -> str:
Args:
config: The configuration for the connector.
"""
if config.get("sqlalchemy_url"):
return super().get_sqlalchemy_url(config)
Expand Down Expand Up @@ -87,6 +88,7 @@ def to_sql_type(self, jsonschema_type: dict) -> sqlalchemy.types.TypeEngine:
Returns:
The SQLAlchemy type representation of the data type.
"""
sql_type = th.to_sql_type(jsonschema_type)

Expand Down Expand Up @@ -135,6 +137,7 @@ def create_empty_table(
Raises:
NotImplementedError: if temp tables are unsupported and as_temp_table=True.
RuntimeError: if a variant schema is passed with no properties defined.
"""
if as_temp_table:
msg = "Temporary tables are not supported."
Expand Down Expand Up @@ -203,6 +206,7 @@ def prepare_schema(self, _: str) -> None:
Args:
schema_name: The target schema name.
"""
return

Expand All @@ -218,6 +222,7 @@ def prepare_column(
full_table_name: the target table name.
column_name: the target column name.
sql_type: the SQLAlchemy type.
"""
if not self.column_exists(full_table_name, column_name):
self._create_empty_column(
Expand Down Expand Up @@ -251,6 +256,7 @@ def get_column_add_ddl(
Returns:
A sqlalchemy DDL instance.
"""
create_column_clause = sqlalchemy.schema.CreateColumn(
sqlalchemy.Column(
Expand Down Expand Up @@ -286,6 +292,7 @@ def get_column_alter_ddl(
Returns:
A sqlalchemy DDL instance.
"""
if self.config.get("cluster_name"):
return sqlalchemy.DDL(
Expand Down
7 changes: 7 additions & 0 deletions target_clickhouse/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def max_size(self) -> int:
Returns
Max number of records to batch before `is_full=True`
"""
return self.MAX_SIZE_DEFAULT

Expand All @@ -48,6 +49,7 @@ def full_table_name(self) -> str:
Returns
The fully qualified table name.
"""
# Use the config table name if set.
_table_name = self.config.get("table_name")
Expand Down Expand Up @@ -86,6 +88,7 @@ def bulk_insert_records(
Returns:
True if table exists, False if not, None if unsure or undetectable.
"""
# Need to convert any records with a dict type to a JSON string.
for record in records:
Expand All @@ -108,6 +111,7 @@ def activate_version(self, new_version: int) -> None:
Args:
new_version: The version number to activate.
"""
# There's nothing to do if the table doesn't exist yet
# (which it won't the first time the stream is processed)
Expand Down Expand Up @@ -167,6 +171,7 @@ def _validate_and_parse(self, record: dict) -> dict:
Returns:
Validated record.
"""
# Pre-validate and correct string type mismatches.
record = pre_validate_for_string_type(record, self.schema, self.logger)
Expand Down Expand Up @@ -201,6 +206,7 @@ def _parse_timestamps_in_record(
record: Individual record in the stream.
schema: TODO
treatment: TODO
"""
for key, value in record.items():
if key not in schema["properties"]:
Expand Down Expand Up @@ -253,6 +259,7 @@ def pre_validate_for_string_type(
Returns:
Record with corrected string type mismatches.
"""
if schema is None:
if logger:
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def singer_filepath(self):
Returns
The expected Path to this tests singer file.
"""
current_file_path = Path(__file__).resolve()
return current_file_path.parent / "target_test_streams" / f"{self.name}.singer"

0 comments on commit 0b284e1

Please sign in to comment.