Skip to content

Commit 0153af4

Browse files
fix lint
1 parent 64e2b02 commit 0153af4

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

src/altertable_flightsql/client.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,14 @@ def prepare(
271271
# Parse result
272272
result = sql_pb2.ActionCreatePreparedStatementResult()
273273
_unpack_command(results[0].body.to_pybytes(), result)
274-
274+
275275
# Extract parameter schema if available
276276
parameter_schema = None
277277
if result.parameter_schema:
278278
parameter_schema = pa.ipc.read_schema(pa.py_buffer(result.parameter_schema))
279-
279+
280280
return PreparedStatement(
281-
self._client,
282-
result.prepared_statement_handle,
283-
parameter_schema=parameter_schema
281+
self._client, result.prepared_statement_handle, parameter_schema=parameter_schema
284282
)
285283

286284
def get_catalogs(self) -> flight.FlightStreamReader:
@@ -456,10 +454,10 @@ class PreparedStatement:
456454
"""
457455

458456
def __init__(
459-
self,
460-
client: flight.FlightClient,
457+
self,
458+
client: flight.FlightClient,
461459
handle: bytes,
462-
parameter_schema: Optional[pa.Schema] = None
460+
parameter_schema: Optional[pa.Schema] = None,
463461
):
464462
"""
465463
Initialize a prepared statement.
@@ -476,7 +474,9 @@ def __init__(
476474
def query(
477475
self,
478476
*,
479-
parameters: Optional[Union[pa.Table, pa.RecordBatch, Mapping[str, Any], Sequence[Any]]] = None,
477+
parameters: Optional[
478+
Union[pa.Table, pa.RecordBatch, Mapping[str, Any], Sequence[Any]]
479+
] = None,
480480
) -> flight.FlightStreamReader:
481481
"""
482482
Execute the prepared statement query.
@@ -490,14 +490,14 @@ def query(
490490
491491
Returns:
492492
FlightStreamReader with query results.
493-
493+
494494
Example:
495495
>>> # Using a dictionary
496496
>>> stmt.query(parameters={"id": 42, "name": "Alice"})
497-
497+
498498
>>> # Using a list
499499
>>> stmt.query(parameters=[42, "Alice"])
500-
500+
501501
>>> # Using a RecordBatch
502502
>>> batch = pa.record_batch({"id": [42], "name": ["Alice"]})
503503
>>> stmt.query(parameters=batch)
@@ -533,7 +533,9 @@ def __exit__(self, exc_type, exc_val, exc_tb) -> None:
533533
"""Context manager exit."""
534534
self.close()
535535

536-
def _get_parameter_as_pyarrow(self, parameters: Union[pa.Table, pa.RecordBatch, Mapping[str, Any], Sequence[Any]]) -> Union[pa.Table, pa.RecordBatch]:
536+
def _get_parameter_as_pyarrow(
537+
self, parameters: Union[pa.Table, pa.RecordBatch, Mapping[str, Any], Sequence[Any]]
538+
) -> Union[pa.Table, pa.RecordBatch]:
537539
if isinstance(parameters, pa.Table):
538540
return parameters
539541
elif isinstance(parameters, pa.RecordBatch):
@@ -546,21 +548,20 @@ def _get_parameter_as_pyarrow(self, parameters: Union[pa.Table, pa.RecordBatch,
546548
"Cannot use positional parameters without parameter schema. "
547549
"Use a dictionary (Mapping[str, Any]) instead."
548550
)
549-
551+
550552
# Create record batch with positional parameters
551553
if len(parameters) != len(self._parameter_schema):
552554
raise ValueError(
553555
f"Expected {len(self._parameter_schema)} parameters, "
554556
f"but got {len(parameters)}"
555557
)
556558
param_dict = {
557-
field.name: [value]
558-
for field, value in zip(self._parameter_schema, parameters)
559+
field.name: [value] for field, value in zip(self._parameter_schema, parameters)
559560
}
560561

561562
return pa.record_batch(param_dict)
562563
else:
563564
raise TypeError(
564565
f"Unsupported parameter type: {type(parameters)}. "
565566
"Expected Table, RecordBatch, Mapping, or Sequence."
566-
)
567+
)

0 commit comments

Comments
 (0)