Skip to content

Commit b4df7cf

Browse files
committed
run black
1 parent e2f18c7 commit b4df7cf

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

data_scribe/components/writers/postgres_comment_writer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def write(self, catalog_data: Dict[str, Any], **kwargs):
7878
"'", "''"
7979
) # Basic SQL escaping
8080

81-
logger.info(f" - Writing comment for VIEW: {schema_name}.{view_name}")
81+
logger.info(
82+
f" - Writing comment for VIEW: {schema_name}.{view_name}"
83+
)
8284
query = f'COMMENT ON VIEW "{schema_name}"."{view_name}" IS %s;'
8385
cursor.execute(query, (description,))
8486

@@ -103,6 +105,10 @@ def write(self, catalog_data: Dict[str, Any], **kwargs):
103105
logger.info("Successfully wrote all comments to PostgreSQL.")
104106

105107
except Exception as e:
106-
logger.error(f"Error writing comments to PostgreSQL: {e}", exc_info=True)
108+
logger.error(
109+
f"Error writing comments to PostgreSQL: {e}", exc_info=True
110+
)
107111
db_connector.connection.rollback() # Rollback on failure
108-
raise WriterError(f"Error writing comments to PostgreSQL: {e}") from e
112+
raise WriterError(
113+
f"Error writing comments to PostgreSQL: {e}"
114+
) from e

data_scribe/core/db_workflow.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ def run(self):
6161
"""
6262
# 1. Determine which database and LLM profiles to use.
6363
# Priority is given to CLI arguments, falling back to defaults in the config file.
64-
db_profile_name = self.db_profile_name or self.config.get("default", {}).get(
65-
"db"
66-
)
67-
llm_profile_name = self.llm_profile_name or self.config.get("default", {}).get(
68-
"llm"
69-
)
64+
db_profile_name = self.db_profile_name or self.config.get(
65+
"default", {}
66+
).get("db")
67+
llm_profile_name = self.llm_profile_name or self.config.get(
68+
"default", {}
69+
).get("llm")
7070

7171
if not db_profile_name or not llm_profile_name:
7272
logger.error(
@@ -97,7 +97,9 @@ def run(self):
9797

9898
try:
9999
# Initialize the writer based on the output profile.
100-
writer_params = self.config["output_profiles"][self.output_profile_name]
100+
writer_params = self.config["output_profiles"][
101+
self.output_profile_name
102+
]
101103
writer_type = writer_params.pop("type")
102104
writer = get_writer(writer_type)
103105

data_scribe/tests/unit/writers/test_postgres_comment_writer.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Unit tests for the PostgresCommentWriter.
33
"""
4+
45
import pytest
56
from unittest.mock import MagicMock
67

@@ -85,7 +86,9 @@ def test_postgres_comment_writer_write_success(
8586
def test_postgres_comment_writer_missing_db_connector():
8687
"""Tests that ConfigError is raised if db_connector is missing."""
8788
writer = PostgresCommentWriter()
88-
with pytest.raises(ConfigError, match="PostgresCommentWriter requires 'db_connector'"):
89+
with pytest.raises(
90+
ConfigError, match="PostgresCommentWriter requires 'db_connector'"
91+
):
8992
writer.write({}, some_other_arg="value")
9093

9194

@@ -94,7 +97,10 @@ def test_postgres_comment_writer_wrong_db_connector_type():
9497
writer = PostgresCommentWriter()
9598
mock_connector = MagicMock(spec=PostgresConnector)
9699
mock_connector.connection = None # Simulate not connected
97-
with pytest.raises(ConfigError, match="PostgresCommentWriter is only compatible with 'postgres'"):
100+
with pytest.raises(
101+
ConfigError,
102+
match="PostgresCommentWriter is only compatible with 'postgres'",
103+
):
98104
writer.write({}, db_connector=MagicMock()) # Pass a generic mock
99105

100106

@@ -110,11 +116,15 @@ def test_postgres_comment_writer_db_error_rollback(
110116
mock_postgres_connector, mock_catalog_data
111117
):
112118
"""Tests that changes are rolled back on database error."""
113-
mock_postgres_connector.cursor.execute.side_effect = Exception("DB write error")
119+
mock_postgres_connector.cursor.execute.side_effect = Exception(
120+
"DB write error"
121+
)
114122

115123
writer = PostgresCommentWriter()
116-
with pytest.raises(WriterError, match="Error writing comments to PostgreSQL"):
124+
with pytest.raises(
125+
WriterError, match="Error writing comments to PostgreSQL"
126+
):
117127
writer.write(mock_catalog_data, db_connector=mock_postgres_connector)
118128

119129
mock_postgres_connector.connection.commit.assert_not_called()
120-
mock_postgres_connector.connection.rollback.assert_called_once()
130+
mock_postgres_connector.connection.rollback.assert_called_once()

0 commit comments

Comments
 (0)