|
1 | 1 | use proc_macro2::{Span, TokenStream};
|
2 |
| -use quote::{quote, quote_spanned}; |
3 | 2 | use pyo3::type_object::PyTypeObject;
|
4 |
| -use pyo3::{PyAny, AsPyRef, PyErr, PyResult, Python, ToPyObject}; |
| 3 | +use pyo3::{AsPyRef, PyAny, PyErr, PyResult, Python, ToPyObject}; |
| 4 | +use quote::{quote, quote_spanned}; |
5 | 5 |
|
6 | 6 | /// Format a nice error message for a python compilation error.
|
7 | 7 | pub fn compile_error_msg(py: Python, error: PyErr, tokens: TokenStream) -> TokenStream {
|
8 | 8 | let value = error.to_object(py);
|
9 | 9 |
|
10 | 10 | if value.is_none(py) {
|
11 | 11 | let error = format!("python: {}", error.ptype.as_ref(py).name());
|
12 |
| - return quote!(compile_error!{#error}); |
| 12 | + return quote!(compile_error! {#error}); |
13 | 13 | }
|
14 | 14 |
|
15 | 15 | if error.matches(py, pyo3::exceptions::SyntaxError::type_object(py)) {
|
@@ -37,7 +37,7 @@ pub fn compile_error_msg(py: Python, error: PyErr, tokens: TokenStream) -> Token
|
37 | 37 | }
|
38 | 38 |
|
39 | 39 | let error = format!("python: {}", value.as_ref(py).str().unwrap());
|
40 |
| - quote!(compile_error!{#error}) |
| 40 | + quote!(compile_error! {#error}) |
41 | 41 | }
|
42 | 42 |
|
43 | 43 | fn get_traceback_info(tb: &PyAny) -> PyResult<(String, usize)> {
|
|
0 commit comments