@@ -638,18 +638,18 @@ def _handle_staging_operation(
638638
639639 # Handle __input_stream__ token for PUT operations
640640 if (
641- row .operation == "PUT" and
642- getattr (row , "localFile" , None ) == "__input_stream__"
641+ row .operation == "PUT"
642+ and getattr (row , "localFile" , None ) == "__input_stream__"
643643 ):
644644 if not self ._input_stream_data :
645645 raise ProgrammingError (
646646 "No input stream provided for streaming operation" ,
647- session_id_hex = self .connection .get_session_id_hex ()
647+ session_id_hex = self .connection .get_session_id_hex (),
648648 )
649649 return self ._handle_staging_put_stream (
650650 presigned_url = row .presignedUrl ,
651651 stream = self ._input_stream_data ,
652- headers = headers
652+ headers = headers ,
653653 )
654654
655655 # For non-streaming operations, validate staging_allowed_local_path
@@ -723,50 +723,50 @@ def _handle_staging_put_stream(
723723 headers : Optional [dict ] = None ,
724724 ) -> None :
725725 """Handle PUT operation with streaming data.
726-
726+
727727 Args:
728728 presigned_url: The presigned URL for upload
729729 stream: Binary stream to upload
730730 headers: Optional HTTP headers
731-
731+
732732 Raises:
733733 OperationalError: If the upload fails
734734 """
735-
735+
736736 # Prepare headers
737737 http_headers = dict (headers ) if headers else {}
738-
738+
739739 try :
740740 # Stream directly to presigned URL
741741 response = requests .put (
742742 url = presigned_url ,
743743 data = stream ,
744744 headers = http_headers ,
745- timeout = 300 # 5 minute timeout
745+ timeout = 300 , # 5 minute timeout
746746 )
747-
747+
748748 # Check response codes
749- OK = requests .codes .ok # 200
750- CREATED = requests .codes .created # 201
751- ACCEPTED = requests .codes .accepted # 202
752- NO_CONTENT = requests .codes .no_content # 204
753-
749+ OK = requests .codes .ok # 200
750+ CREATED = requests .codes .created # 201
751+ ACCEPTED = requests .codes .accepted # 202
752+ NO_CONTENT = requests .codes .no_content # 204
753+
754754 if response .status_code not in [OK , CREATED , NO_CONTENT , ACCEPTED ]:
755755 raise OperationalError (
756756 f"Staging operation over HTTP was unsuccessful: { response .status_code } -{ response .text } " ,
757- session_id_hex = self .connection .get_session_id_hex ()
757+ session_id_hex = self .connection .get_session_id_hex (),
758758 )
759-
759+
760760 if response .status_code == ACCEPTED :
761761 logger .debug (
762762 f"Response code { ACCEPTED } from server indicates upload was accepted "
763763 "but not yet applied on the server. It's possible this command may fail later."
764764 )
765-
765+
766766 except requests .exceptions .RequestException as e :
767767 raise OperationalError (
768768 f"HTTP request failed during stream upload: { str (e )} " ,
769- session_id_hex = self .connection .get_session_id_hex ()
769+ session_id_hex = self .connection .get_session_id_hex (),
770770 ) from e
771771
772772 @log_latency (StatementType .SQL )
@@ -899,7 +899,7 @@ def execute(
899899 self ._input_stream_data = None
900900 if input_stream is not None :
901901 # Validate stream has required methods
902- if not hasattr (input_stream , ' read' ):
902+ if not hasattr (input_stream , " read" ):
903903 raise TypeError (
904904 "input_stream must be a binary stream with read() method"
905905 )
@@ -916,7 +916,9 @@ def execute(
916916 )
917917 elif param_approach == ParameterApproach .NATIVE :
918918 normalized_parameters = self ._normalize_tparametercollection (parameters )
919- param_structure = self ._determine_parameter_structure (normalized_parameters )
919+ param_structure = self ._determine_parameter_structure (
920+ normalized_parameters
921+ )
920922 transformed_operation = transform_paramstyle (
921923 operation , normalized_parameters , param_structure
922924 )
0 commit comments