Skip to content

Commit a19365c

Browse files
committed
use pyo3 error type
1 parent 8e85a60 commit a19365c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/validators/model_fields.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use pyo3::exceptions::PyKeyError;
1+
use pyo3::exceptions::{PyDeprecationWarning, PyKeyError};
22
use pyo3::intern;
33
use pyo3::prelude::*;
44
use pyo3::types::{PyDict, PySet, PyString, PyType};
5+
use pyo3::PyTypeInfo;
56

67
use ahash::AHashSet;
78

@@ -187,7 +188,7 @@ impl Validator for ModelFieldsValidator {
187188
used_keys.insert(lookup_path.first_key());
188189
}
189190
if let Some(msg) = &field.deprecation_msg {
190-
let deprecation_warning_type = py.import_bound("builtins")?.getattr("DeprecationWarning")?;
191+
let deprecation_warning_type = PyDeprecationWarning::type_object_bound(py);
191192
PyErr::warn_bound(py, &deprecation_warning_type, msg, 2)?;
192193
}
193194
match field.validator.validate(py, value.borrow_input(), state) {

0 commit comments

Comments
 (0)