22// See: https://github.com/PyO3/pyo3/issues/4327
33#![ allow( clippy:: useless_conversion) ]
44
5- use pyo3:: prelude:: * ;
65use pyo3:: create_exception;
76use pyo3:: exceptions:: PyValueError ;
7+ use pyo3:: prelude:: * ;
88use pyo3:: types:: { PyBytes , PyDict , PyList } ;
99use std:: io:: Cursor ;
1010
@@ -19,10 +19,30 @@ use ggsql::GgsqlError;
1919// ============================================================================
2020
2121// All subclass ValueError for backwards compatibility
22- create_exception ! ( ggsql, ParseError , PyValueError , "Raised on query syntax errors." ) ;
23- create_exception ! ( ggsql, ValidationError , PyValueError , "Raised on semantic validation errors." ) ;
24- create_exception ! ( ggsql, ReaderError , PyValueError , "Raised on data source errors." ) ;
25- create_exception ! ( ggsql, WriterError , PyValueError , "Raised on output generation errors." ) ;
22+ create_exception ! (
23+ ggsql,
24+ ParseError ,
25+ PyValueError ,
26+ "Raised on query syntax errors."
27+ ) ;
28+ create_exception ! (
29+ ggsql,
30+ ValidationError ,
31+ PyValueError ,
32+ "Raised on semantic validation errors."
33+ ) ;
34+ create_exception ! (
35+ ggsql,
36+ ReaderError ,
37+ PyValueError ,
38+ "Raised on data source errors."
39+ ) ;
40+ create_exception ! (
41+ ggsql,
42+ WriterError ,
43+ PyValueError ,
44+ "Raised on output generation errors."
45+ ) ;
2646
2747/// Convert a GgsqlError to the appropriate typed Python exception.
2848fn ggsql_err_to_py ( e : GgsqlError ) -> PyErr {
@@ -252,8 +272,8 @@ impl PyDuckDBReader {
252272 /// If the connection string is invalid or the database cannot be opened.
253273 #[ new]
254274 fn new ( connection : & str ) -> PyResult < Self > {
255- let inner = RustDuckDBReader :: from_connection_string ( connection )
256- . map_err ( ggsql_err_to_py) ?;
275+ let inner =
276+ RustDuckDBReader :: from_connection_string ( connection ) . map_err ( ggsql_err_to_py) ?;
257277 Ok ( Self { inner } )
258278 }
259279
@@ -298,9 +318,7 @@ impl PyDuckDBReader {
298318 /// ValueError
299319 /// If the table wasn't registered via this reader or unregistration fails.
300320 fn unregister ( & self , name : & str ) -> PyResult < ( ) > {
301- self . inner
302- . unregister ( name)
303- . map_err ( ggsql_err_to_py)
321+ self . inner . unregister ( name) . map_err ( ggsql_err_to_py)
304322 }
305323
306324 /// Execute a SQL query and return the result as a DataFrame.
@@ -320,10 +338,7 @@ impl PyDuckDBReader {
320338 /// ValueError
321339 /// If the SQL is invalid or execution fails.
322340 fn execute_sql ( & self , py : Python < ' _ > , sql : & str ) -> PyResult < Py < PyAny > > {
323- let df = self
324- . inner
325- . execute_sql ( sql)
326- . map_err ( ggsql_err_to_py) ?;
341+ let df = self . inner . execute_sql ( sql) . map_err ( ggsql_err_to_py) ?;
327342 polars_to_py ( py, & df)
328343 }
329344
@@ -419,9 +434,7 @@ impl PyVegaLiteWriter {
419434 /// >>> writer = VegaLiteWriter()
420435 /// >>> json_output = writer.render(spec)
421436 fn render ( & self , spec : & PySpec ) -> PyResult < String > {
422- self . inner
423- . render ( & spec. inner )
424- . map_err ( ggsql_err_to_py)
437+ self . inner . render ( & spec. inner ) . map_err ( ggsql_err_to_py)
425438 }
426439}
427440
@@ -685,8 +698,7 @@ impl PySpec {
685698/// If validation fails unexpectedly (not for syntax errors, which are captured).
686699#[ pyfunction]
687700fn validate ( query : & str ) -> PyResult < PyValidated > {
688- let v = rust_validate ( query)
689- . map_err ( ggsql_err_to_py) ?;
701+ let v = rust_validate ( query) . map_err ( ggsql_err_to_py) ?;
690702
691703 Ok ( PyValidated {
692704 sql : v. sql ( ) . to_string ( ) ,
0 commit comments