Skip to content

Commit a55ab60

Browse files
sdks/python: fix linting issues
1 parent 5462138 commit a55ab60

File tree

1 file changed

+7
-6
lines changed
  • sdks/python/apache_beam/transforms/enrichment_handlers

1 file changed

+7
-6
lines changed

sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,8 @@ def __enter__(self):
317317
url=self._connection_config.get_db_url(), creator=connector)
318318

319319
def _execute_query(
320-
self,
321-
query: str,
322-
is_batch: bool,
323-
**params) -> Union[List[Dict[str, Any]], Dict[str, Any]]:
320+
self, query: str, is_batch: bool,
321+
**params: Dict[str, Any]) -> Union[List[Dict[str, Any]], Dict[str, Any]]:
324322
connection = None
325323
try:
326324
connection = self._engine.connect()
@@ -329,10 +327,13 @@ def _execute_query(
329327
result = connection.execute(text(query), **params)
330328
# Materialize results while transaction is active.
331329
if is_batch:
332-
data = [row._asdict() for row in result]
330+
data: List[Dict[str, Any]] = [row._asdict() for row in result]
333331
else:
334332
result_row = result.first()
335-
data = result_row._asdict() if result_row else {}
333+
if result_row:
334+
data: Dict[str, Any] = result_row._asdict()
335+
else:
336+
data = {}
336337
# Explicitly commit the transaction.
337338
transaction.commit()
338339
return data

0 commit comments

Comments
 (0)