Skip to content

Commit 8dfbfe4

Browse files
fixing all files with pre-commit
1 parent 54d9f80 commit 8dfbfe4

File tree

6 files changed

+66
-57
lines changed

6 files changed

+66
-57
lines changed

src/snowflake/connector/connection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ def execute_stream(
894894
remove_comments: bool = False,
895895
cursor_class: SnowflakeCursor = SnowflakeCursor,
896896
**kwargs,
897-
) -> Generator[SnowflakeCursor, None, None]:
897+
) -> Generator[SnowflakeCursor]:
898898
"""Executes a stream of SQL statements. This is a non-standard convenient method."""
899899
split_statements_list = split_statements(
900900
stream, remove_comments=remove_comments

src/snowflake/connector/gzip_decoder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def decompress_raw_data_by_zcat(raw_data_fd: IO, add_bracket: bool = True) -> by
6767

6868
def decompress_raw_data_to_unicode_stream(
6969
raw_data_fd: IO,
70-
) -> Generator[str, None, None]:
70+
) -> Generator[str]:
7171
"""Decompresses a raw data in file like object and yields a Unicode string.
7272
7373
Args:

src/snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_ipc.c

+45-32
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
flatbuffers_voffset_t id__tmp, *vt__tmp; \
1818
FLATCC_ASSERT(t != 0 && "null pointer table access"); \
1919
id__tmp = ID; \
20-
vt__tmp = (flatbuffers_voffset_t *)(( \
21-
uint8_t *)(t)-__flatbuffers_soffset_read_from_pe(t)); \
20+
vt__tmp = \
21+
(flatbuffers_voffset_t *)((uint8_t *)(t) - \
22+
__flatbuffers_soffset_read_from_pe(t)); \
2223
if (__flatbuffers_voffset_read_from_pe(vt__tmp) >= \
2324
sizeof(vt__tmp[0]) * (id__tmp + 3u)) { \
2425
offset = __flatbuffers_voffset_read_from_pe(vt__tmp + id__tmp + 2); \
2526
} \
2627
}
27-
#define __flatbuffers_field_present(ID, t) \
28-
{ __flatbuffers_read_vt(ID, offset__tmp, t) return offset__tmp != 0; }
28+
#define __flatbuffers_field_present(ID, t) \
29+
{ \
30+
__flatbuffers_read_vt(ID, offset__tmp, t) return offset__tmp != 0; \
31+
}
2932
#define __flatbuffers_scalar_field(T, ID, t) \
3033
{ \
3134
__flatbuffers_read_vt(ID, offset__tmp, t) if (offset__tmp) { \
@@ -222,27 +225,27 @@ static inline flatbuffers_string_t flatbuffers_string_cast_from_union(
222225
const flatbuffers_union_t u__tmp) {
223226
return flatbuffers_string_cast_from_generic(u__tmp.value);
224227
}
225-
#define __flatbuffers_define_union_field(NS, ID, N, NK, T, r) \
226-
static inline T##_union_type_t N##_##NK##_type_get(N##_table_t t__tmp) \
227-
__##NS##union_type_field(((ID)-1), t__tmp) static inline NS##generic_t \
228-
N##_##NK##_get(N##_table_t t__tmp) __##NS##table_field( \
229-
NS##generic_t, ID, t__tmp, r) static inline T##_union_type_t \
230-
N##_##NK##_type(N##_table_t t__tmp) __##NS##union_type_field( \
231-
((ID)-1), t__tmp) static inline NS##generic_t \
232-
N##_##NK(N##_table_t t__tmp) __##NS##table_field( \
233-
NS##generic_t, ID, t__tmp, r) static inline int \
234-
N##_##NK##_is_present(N##_table_t t__tmp) \
235-
__##NS##field_present( \
236-
ID, t__tmp) static inline T##_union_t \
237-
N##_##NK##_union(N##_table_t t__tmp) { \
238-
T##_union_t u__tmp = {0, 0}; \
239-
u__tmp.type = N##_##NK##_type_get(t__tmp); \
240-
if (u__tmp.type == 0) return u__tmp; \
241-
u__tmp.value = N##_##NK##_get(t__tmp); \
242-
return u__tmp; \
243-
} \
244-
static inline NS##string_t N##_##NK##_as_string(N##_table_t t__tmp) { \
245-
return NS##string_cast_from_generic(N##_##NK##_get(t__tmp)); \
228+
#define __flatbuffers_define_union_field(NS, ID, N, NK, T, r) \
229+
static inline T##_union_type_t N##_##NK##_type_get(N##_table_t t__tmp) \
230+
__##NS##union_type_field(((ID) - 1), t__tmp) static inline NS##generic_t \
231+
N##_##NK##_get(N##_table_t t__tmp) __##NS##table_field( \
232+
NS##generic_t, ID, t__tmp, r) static inline T##_union_type_t \
233+
N##_##NK##_type(N##_table_t t__tmp) __##NS##union_type_field( \
234+
((ID) - 1), t__tmp) static inline NS##generic_t \
235+
N##_##NK(N##_table_t t__tmp) __##NS##table_field( \
236+
NS##generic_t, ID, t__tmp, r) static inline int \
237+
N##_##NK##_is_present(N##_table_t t__tmp) \
238+
__##NS##field_present( \
239+
ID, t__tmp) static inline T##_union_t \
240+
N##_##NK##_union(N##_table_t t__tmp) { \
241+
T##_union_t u__tmp = {0, 0}; \
242+
u__tmp.type = N##_##NK##_type_get(t__tmp); \
243+
if (u__tmp.type == 0) return u__tmp; \
244+
u__tmp.value = N##_##NK##_get(t__tmp); \
245+
return u__tmp; \
246+
} \
247+
static inline NS##string_t N##_##NK##_as_string(N##_table_t t__tmp) { \
248+
return NS##string_cast_from_generic(N##_##NK##_get(t__tmp)); \
246249
}
247250

248251
#define __flatbuffers_define_union_vector_ops(NS, T) \
@@ -703,10 +706,14 @@ static inline int __flatbuffers_string_cmp(flatbuffers_string_t v,
703706
T##_mutable_vec_t v__tmp = (T##_mutable_vec_t)N##_##NK##_get(t); \
704707
if (v__tmp) T##_vec_sort(v__tmp); \
705708
}
706-
#define __flatbuffers_sort_table_field(N, NK, T, t) \
707-
{ T##_sort((T##_mutable_table_t)N##_##NK##_get(t)); }
708-
#define __flatbuffers_sort_union_field(N, NK, T, t) \
709-
{ T##_sort(T##_mutable_union_cast(N##_##NK##_union(t))); }
709+
#define __flatbuffers_sort_table_field(N, NK, T, t) \
710+
{ \
711+
T##_sort((T##_mutable_table_t)N##_##NK##_get(t)); \
712+
}
713+
#define __flatbuffers_sort_union_field(N, NK, T, t) \
714+
{ \
715+
T##_sort(T##_mutable_union_cast(N##_##NK##_union(t))); \
716+
}
710717
#define __flatbuffers_sort_table_vector_field_elements(N, NK, T, t) \
711718
{ \
712719
T##_vec_t v__tmp = N##_##NK##_get(t); \
@@ -12006,7 +12013,9 @@ static inline size_t org_apache_arrow_flatbuf_Tensor_vec_len(
1200612013
#endif
1200712014

1200812015
static const flatbuffers_voffset_t
12009-
__org_apache_arrow_flatbuf_TensorDim_required[] = {0};
12016+
__org_apache_arrow_flatbuf_TensorDim_required[] = {
12017+
0
12018+
};
1201012019
typedef flatbuffers_ref_t org_apache_arrow_flatbuf_TensorDim_ref_t;
1201112020
static org_apache_arrow_flatbuf_TensorDim_ref_t
1201212021
org_apache_arrow_flatbuf_TensorDim_clone(
@@ -24265,7 +24274,9 @@ static inline size_t org_apache_arrow_flatbuf_Tensor_vec_len(
2426524274
#endif
2426624275

2426724276
static const flatbuffers_voffset_t
24268-
__org_apache_arrow_flatbuf_TensorDim_required[] = {0};
24277+
__org_apache_arrow_flatbuf_TensorDim_required[] = {
24278+
0
24279+
};
2426924280
typedef flatbuffers_ref_t org_apache_arrow_flatbuf_TensorDim_ref_t;
2427024281
static org_apache_arrow_flatbuf_TensorDim_ref_t
2427124282
org_apache_arrow_flatbuf_TensorDim_clone(
@@ -30667,7 +30678,9 @@ static inline size_t org_apache_arrow_flatbuf_Tensor_vec_len(
3066730678
#endif
3066830679

3066930680
static const flatbuffers_voffset_t
30670-
__org_apache_arrow_flatbuf_TensorDim_required[] = {0};
30681+
__org_apache_arrow_flatbuf_TensorDim_required[] = {
30682+
0
30683+
};
3067130684
typedef flatbuffers_ref_t org_apache_arrow_flatbuf_TensorDim_ref_t;
3067230685
static org_apache_arrow_flatbuf_TensorDim_ref_t
3067330686
org_apache_arrow_flatbuf_TensorDim_clone(

test/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def patch_connection(
5555
self,
5656
con: SnowflakeConnection,
5757
propagate: bool = True,
58-
) -> Generator[TelemetryCaptureHandler, None, None]:
58+
) -> Generator[TelemetryCaptureHandler]:
5959
original_telemetry = con._telemetry
6060
new_telemetry = TelemetryCaptureHandler(
6161
original_telemetry,

test/integ/conftest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def get_db_parameters(connection_name: str = "default") -> dict[str, Any]:
163163

164164

165165
@pytest.fixture(scope="session", autouse=True)
166-
def init_test_schema(db_parameters) -> Generator[None, None, None]:
166+
def init_test_schema(db_parameters) -> Generator[None]:
167167
"""Initializes and destroys the schema specific to this pytest session.
168168
169169
This is automatically called per test session.
@@ -200,7 +200,7 @@ def create_connection(connection_name: str, **kwargs) -> SnowflakeConnection:
200200
def db(
201201
connection_name: str = "default",
202202
**kwargs,
203-
) -> Generator[SnowflakeConnection, None, None]:
203+
) -> Generator[SnowflakeConnection]:
204204
if not kwargs.get("timezone"):
205205
kwargs["timezone"] = "UTC"
206206
if not kwargs.get("converter_class"):
@@ -216,7 +216,7 @@ def db(
216216
def negative_db(
217217
connection_name: str = "default",
218218
**kwargs,
219-
) -> Generator[SnowflakeConnection, None, None]:
219+
) -> Generator[SnowflakeConnection]:
220220
if not kwargs.get("timezone"):
221221
kwargs["timezone"] = "UTC"
222222
if not kwargs.get("converter_class"):

test/integ/pandas/test_pandas_tools.py

+15-19
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ def assert_result_equals(
6363
assert set(cnx.cursor().execute(sql).fetchall()) == set(expected_data)
6464

6565

66-
def test_fix_snow_746341(
67-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]]
68-
):
66+
def test_fix_snow_746341(conn_cnx: Callable[..., Generator[SnowflakeConnection]]):
6967
cat = '"cat"'
7068
df = pandas.DataFrame([[1], [2]], columns=[f"col_'{cat}'"])
7169
table_name = random_string(5, "snow746341_")
@@ -83,7 +81,7 @@ def test_fix_snow_746341(
8381
@pytest.mark.parametrize("auto_create_table", [True, False])
8482
@pytest.mark.parametrize("index", [False])
8583
def test_write_pandas_with_overwrite(
86-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
84+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
8785
quote_identifiers: bool,
8886
auto_create_table: bool,
8987
index: bool,
@@ -225,7 +223,7 @@ def test_write_pandas_with_overwrite(
225223
@pytest.mark.parametrize("create_temp_table", [True, False])
226224
@pytest.mark.parametrize("index", [False])
227225
def test_write_pandas(
228-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
226+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
229227
db_parameters: dict[str, str],
230228
compression: str,
231229
chunk_size: int,
@@ -296,7 +294,7 @@ def test_write_pandas(
296294

297295

298296
def test_write_non_range_index_pandas(
299-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
297+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
300298
db_parameters: dict[str, str],
301299
):
302300
compression = "gzip"
@@ -376,7 +374,7 @@ def test_write_non_range_index_pandas(
376374

377375
@pytest.mark.parametrize("table_type", ["", "temp", "temporary", "transient"])
378376
def test_write_pandas_table_type(
379-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
377+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
380378
table_type: str,
381379
):
382380
with conn_cnx() as cnx:
@@ -408,7 +406,7 @@ def test_write_pandas_table_type(
408406

409407

410408
def test_write_pandas_create_temp_table_deprecation_warning(
411-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
409+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
412410
):
413411
with conn_cnx() as cnx:
414412
table_name = random_string(5, "driver_versions_")
@@ -436,7 +434,7 @@ def test_write_pandas_create_temp_table_deprecation_warning(
436434

437435
@pytest.mark.parametrize("use_logical_type", [None, True, False])
438436
def test_write_pandas_use_logical_type(
439-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
437+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
440438
use_logical_type: bool | None,
441439
):
442440
table_name = random_string(5, "USE_LOCAL_TYPE_").upper()
@@ -483,7 +481,7 @@ def test_write_pandas_use_logical_type(
483481

484482

485483
def test_invalid_table_type_write_pandas(
486-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
484+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
487485
):
488486
with conn_cnx() as cnx:
489487
with pytest.raises(ValueError, match="Unsupported table type"):
@@ -496,7 +494,7 @@ def test_invalid_table_type_write_pandas(
496494

497495

498496
def test_empty_dataframe_write_pandas(
499-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
497+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
500498
):
501499
table_name = random_string(5, "empty_dataframe_")
502500
df = pandas.DataFrame([], columns=["name", "balance"])
@@ -720,7 +718,7 @@ def mocked_execute(*args, **kwargs):
720718

721719
@pytest.mark.parametrize("quote_identifiers", [True, False])
722720
def test_default_value_insertion(
723-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
721+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
724722
quote_identifiers: bool,
725723
):
726724
"""Tests whether default values can be successfully inserted with the pandas writeback."""
@@ -774,7 +772,7 @@ def test_default_value_insertion(
774772

775773
@pytest.mark.parametrize("quote_identifiers", [True, False])
776774
def test_autoincrement_insertion(
777-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
775+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
778776
quote_identifiers: bool,
779777
):
780778
"""Tests whether default values can be successfully inserted with the pandas writeback."""
@@ -828,7 +826,7 @@ def test_autoincrement_insertion(
828826
],
829827
)
830828
def test_special_name_quoting(
831-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
829+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
832830
auto_create_table: bool,
833831
column_names: list[str],
834832
):
@@ -875,7 +873,7 @@ def test_special_name_quoting(
875873

876874

877875
def test_auto_create_table_similar_column_names(
878-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
876+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
879877
):
880878
"""Tests whether similar names do not cause issues when auto-creating a table as expected."""
881879
table_name = random_string(5, "numbas_")
@@ -905,9 +903,7 @@ def test_auto_create_table_similar_column_names(
905903
cnx.execute_string(drop_sql)
906904

907905

908-
def test_all_pandas_types(
909-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]]
910-
):
906+
def test_all_pandas_types(conn_cnx: Callable[..., Generator[SnowflakeConnection]]):
911907
table_name = random_string(5, "all_types_")
912908
datetime_with_tz = datetime(1997, 6, 3, 14, 21, 32, 00, tzinfo=timezone.utc)
913909
datetime_with_ntz = datetime(1997, 6, 3, 14, 21, 32, 00)
@@ -979,7 +975,7 @@ def test_all_pandas_types(
979975

980976
@pytest.mark.parametrize("object_type", ["STAGE", "FILE FORMAT"])
981977
def test_no_create_internal_object_privilege_in_target_schema(
982-
conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]],
978+
conn_cnx: Callable[..., Generator[SnowflakeConnection]],
983979
caplog,
984980
object_type,
985981
):

0 commit comments

Comments
 (0)