|
1 | 1 | use std::error::Error;
|
2 | 2 | use std::fmt;
|
3 | 3 |
|
4 |
| -use crate::tools::py_err; |
5 |
| -use pyo3::exceptions::{PyException, PyTypeError}; |
| 4 | +use pyo3::exceptions::PyException; |
6 | 5 | use pyo3::prelude::*;
|
7 | 6 | use pyo3::types::{PyDict, PyList, PyString};
|
8 | 7 | use pyo3::{intern, FromPyObject, PyErrArguments};
|
@@ -196,30 +195,3 @@ impl ExtraBehavior {
|
196 | 195 | Ok(res)
|
197 | 196 | }
|
198 | 197 | }
|
199 |
| - |
200 |
| -impl ToPyObject for ExtraBehavior { |
201 |
| - fn to_object(&self, _py: Python) -> PyObject { |
202 |
| - match self { |
203 |
| - ExtraBehavior::Allow => ExtraBehavior::Allow.to_object(_py), |
204 |
| - ExtraBehavior::Ignore => ExtraBehavior::Ignore.to_object(_py), |
205 |
| - ExtraBehavior::Forbid => ExtraBehavior::Forbid.to_object(_py), |
206 |
| - } |
207 |
| - } |
208 |
| -} |
209 |
| - |
210 |
| -impl FromPyObject<'_> for ExtraBehavior { |
211 |
| - fn extract(obj: &PyAny) -> PyResult<Self> { |
212 |
| - if let Ok(string) = obj.extract::<String>() { |
213 |
| - Ok(match string.as_str() { |
214 |
| - "allow" => ExtraBehavior::Allow, |
215 |
| - "ignore" => ExtraBehavior::Ignore, |
216 |
| - "forbid" => ExtraBehavior::Forbid, |
217 |
| - _ => { |
218 |
| - return py_err!(PyTypeError; "Invalid string for ExtraBehavior. Possible values are allow, ignore and forbid") |
219 |
| - } |
220 |
| - }) |
221 |
| - } else { |
222 |
| - py_err!(PyTypeError; "Expected string value, got {}", obj.get_type()) |
223 |
| - } |
224 |
| - } |
225 |
| -} |
0 commit comments