109109    ER_NO_USER ,
110110    ER_NOT_IMPLICITY_SNOWFLAKE_DATATYPE ,
111111)
112- from  .errors  import  DatabaseError , Error , OperationalError , ProgrammingError 
112+ from  .errors  import  (
113+     DatabaseError ,
114+     Error ,
115+     ErrorHandler ,
116+     OperationalError ,
117+     ProgrammingError ,
118+ )
113119from  .log_configuration  import  EasyLoggingConfigPython 
114120from  .network  import  (
115121    DEFAULT_AUTHENTICATOR ,
@@ -500,6 +506,12 @@ class SnowflakeConnection:
500506
501507    OCSP_ENV_LOCK  =  Lock ()
502508
509+     # Tell mypy these fields exist. 
510+     # TODO: Replace the dynamic setattr() with static methods 
511+     _interpolate_empty_sequences : bool 
512+     _reraise_error_in_file_transfer_work_function : bool 
513+     _reuse_results : bool 
514+ 
503515    def  __init__ (
504516        self ,
505517        connection_name : str  |  None  =  None ,
@@ -780,12 +792,12 @@ def application(self) -> str:
780792        return  self ._application 
781793
782794    @property  
783-     def  errorhandler (self ) ->  Callable :   # TODO: callable args 
795+     def  errorhandler (self ) ->  ErrorHandler : 
784796        return  self ._errorhandler 
785797
786798    @errorhandler .setter  
787-     # Note: Callable doesn't implement operator| 
788-     def   errorhandler ( self ,  value :  Callable   |  None )  ->   None : 
799+     def   errorhandler ( self ,  value :  ErrorHandler   |   None )  ->   None : 
800+          # TODO: Why is value `ErrorHandler  | None` if it always errors on  None? 
789801        if  value  is  None :
790802            raise  ProgrammingError ("None errorhandler is specified" )
791803        self ._errorhandler  =  value 
@@ -1096,9 +1108,9 @@ def execute_string(
10961108        sql_text : str ,
10971109        remove_comments : bool  =  False ,
10981110        return_cursors : bool  =  True ,
1099-         cursor_class : SnowflakeCursor  =  SnowflakeCursor ,
1111+         cursor_class : SnowflakeCursorBase  =  SnowflakeCursor ,
11001112        ** kwargs ,
1101-     ) ->  Iterable [SnowflakeCursor ]:
1113+     ) ->  Iterable [SnowflakeCursorBase ]:
11021114        """Executes a SQL text including multiple statements. This is a non-standard convenience method.""" 
11031115        stream  =  StringIO (sql_text )
11041116        stream_generator  =  self .execute_stream (
@@ -1111,9 +1123,9 @@ def execute_stream(
11111123        self ,
11121124        stream : StringIO ,
11131125        remove_comments : bool  =  False ,
1114-         cursor_class : SnowflakeCursor  =  SnowflakeCursor ,
1126+         cursor_class : SnowflakeCursorBase  =  SnowflakeCursor ,
11151127        ** kwargs ,
1116-     ) ->  Generator [SnowflakeCursor ]:
1128+     ) ->  Generator [SnowflakeCursorBase ]:
11171129        """Executes a stream of SQL statements. This is a non-standard convenient method.""" 
11181130        split_statements_list  =  split_statements (
11191131            stream , remove_comments = remove_comments 
@@ -1830,7 +1842,6 @@ def _write_params_to_byte_rows(
18301842
18311843        Args: 
18321844            params: Binding parameters to bulk array insertion query with qmark/numeric format. 
1833-             cursor: SnowflakeCursor. 
18341845
18351846        Returns: 
18361847            List of bytes string corresponding to rows 
@@ -1847,7 +1858,7 @@ def _write_params_to_byte_rows(
18471858
18481859    def  _get_snowflake_type_and_binding (
18491860        self ,
1850-         cursor : SnowflakeCursor  |  None ,
1861+         cursor : SnowflakeCursorBase  |  None ,
18511862        v : tuple [str , Any ] |  Any ,
18521863    ) ->  TypeAndBinding :
18531864        if  isinstance (v , tuple ):
@@ -1888,7 +1899,7 @@ def _get_snowflake_type_and_binding(
18881899    def  _process_params_qmarks (
18891900        self ,
18901901        params : Sequence  |  None ,
1891-         cursor : SnowflakeCursor  |  None  =  None ,
1902+         cursor : SnowflakeCursorBase  |  None  =  None ,
18921903    ) ->  dict [str , dict [str , str ]] |  None :
18931904        if  not  params :
18941905            return  None 
@@ -1922,14 +1933,14 @@ def _process_params_qmarks(
19221933    def  _process_params_pyformat (
19231934        self ,
19241935        params : Any  |  Sequence [Any ] |  dict [Any , Any ] |  None ,
1925-         cursor : SnowflakeCursor  |  None  =  None ,
1936+         cursor : SnowflakeCursorBase  |  None  =  None ,
19261937    ) ->  tuple [Any ] |  dict [str , Any ] |  None :
19271938        """Process parameters for client-side parameter binding. 
19281939
19291940        Args: 
19301941            params: Either a sequence, or a dictionary of parameters, if anything else 
19311942                is given then it will be put into a list and processed that way. 
1932-             cursor: The SnowflakeCursor  used to report errors if necessary. 
1943+             cursor: The SnowflakeCursorBase  used to report errors if necessary. 
19331944        """ 
19341945        if  params  is  None :
19351946            if  self ._interpolate_empty_sequences :
@@ -1961,7 +1972,7 @@ def _process_params_pyformat(
19611972            )
19621973
19631974    def  _process_params_dict (
1964-         self , params : dict [Any , Any ], cursor : SnowflakeCursor  |  None  =  None 
1975+         self , params : dict [Any , Any ], cursor : SnowflakeCursorBase  |  None  =  None 
19651976    ) ->  dict :
19661977        try :
19671978            res  =  {k : self ._process_single_param (v ) for  k , v  in  params .items ()}
0 commit comments