Skip to content

Commit 0c9fe23

Browse files
committed
chore(cursor): lint
1 parent 476a1de commit 0c9fe23

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

redshift_connector/cursor.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,10 @@ def executemany(self: "Cursor", operation, param_sets) -> "Cursor":
262262
self._redshift_row_count = -1 if -1 in redshift_rowcounts else sum(rowcounts)
263263
return self
264264

265-
def insert_data_bulk(
266-
self: "Cursor", filename, table_name, column_indexes, column_names, delimeter
267-
) -> "Cursor":
265+
def insert_data_bulk(self: "Cursor", filename, table_name, column_indexes, column_names, delimeter) -> "Cursor":
268266

269267
"""runs a single bulk insert statement into the database.
270-
271268
This method is native to redshift_connector.
272-
273269
:param filename: str
274270
The name of the file to read from.
275271
:param table_name: str
@@ -280,21 +276,14 @@ def insert_data_bulk(
280276
The indexes of the columns in the table to insert to.
281277
:param delimeter: str
282278
The delimeter to use when reading the file.
283-
284279
Returns
285-
286280
-------
287281
The Cursor object used for executing the specified database operation: :class:`Cursor`
288-
289282
"""
290283
if not self.__is_valid_table(table_name):
291-
raise InterfaceError(
292-
"Invalid table name passed to insert_data_bulk: {}".format(table_name)
293-
)
284+
raise InterfaceError("Invalid table name passed to insert_data_bulk: {}".format(table_name))
294285
if not self.__has_valid_columns(table_name, column_names):
295-
raise InterfaceError(
296-
"Invalid column names passed to insert_data_bulk: {}".format(table_name)
297-
)
286+
raise InterfaceError("Invalid column names passed to insert_data_bulk: {}".format(table_name))
298287
orig_paramstyle = self.paramstyle
299288
import csv
300289

@@ -325,16 +314,12 @@ def insert_data_bulk(
325314

326315
return self
327316

328-
def __has_valid_columns(
329-
self: "Cursor", table: str, columns: typing.List[str]
330-
) -> bool:
317+
def __has_valid_columns(self: "Cursor", table: str, columns: typing.List[str]) -> bool:
331318
split_table_name: typing.List[str] = table.split(".")
332319
q: str = "select 1 from information_schema.columns where table_name = ? and column_name = ?"
333320
if len(split_table_name) == 2:
334321
q += " and table_schema = ?"
335-
param_list = [
336-
[split_table_name[1], c, split_table_name[0]] for c in columns
337-
]
322+
param_list = [[split_table_name[1], c, split_table_name[0]] for c in columns]
338323
else:
339324
param_list = [[split_table_name[0], c] for c in columns]
340325
temp = self.paramstyle
@@ -344,11 +329,7 @@ def __has_valid_columns(
344329
self.execute(q, params)
345330
res = self.fetchone()
346331
if typing.cast(typing.List[int], res)[0] != 1:
347-
raise InterfaceError(
348-
"Invalid column name: {} specified for table: {}".format(
349-
params[1], table
350-
)
351-
)
332+
raise InterfaceError("Invalid column name: {} specified for table: {}".format(params[1], table))
352333
except:
353334
raise
354335
finally:

test/unit/test_cursor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import typing
22
from test.utils import pandas_only
3-
from unittest.mock import Mock, PropertyMock, patch ,mock_open
3+
from unittest.mock import Mock, PropertyMock, mock_open, patch
44

55
import pytest # type: ignore
66

@@ -262,9 +262,7 @@ def test_insert_data_column_names_indexes_mismatch_raises(indexes, names, mocker
262262
mock_cursor._c = Mock()
263263
mock_cursor.paramstyle = "qmark"
264264

265-
with pytest.raises(
266-
InterfaceError, match="Column names and indexes must be the same length"
267-
):
265+
with pytest.raises(InterfaceError, match="Column names and indexes must be the same length"):
268266
mock_cursor.insert_data_bulk(
269267
filename="test_file",
270268
table_name="test_table",

0 commit comments

Comments
 (0)