@@ -2,18 +2,17 @@ use num_bigint::BigInt;
22use pyo3:: exceptions:: PyValueError ;
33use pyo3:: intern;
44use pyo3:: prelude:: * ;
5- use pyo3:: types:: { PyDict , PyString } ;
5+ use pyo3:: types:: PyDict ;
66use pyo3:: IntoPyObjectExt ;
77
88use crate :: build_tools:: is_strict;
99use crate :: errors:: { ErrorType , ValError , ValResult } ;
1010use crate :: input:: { Input , Int } ;
11- use crate :: tools:: SchemaDict ;
1211
1312use super :: { BuildValidator , CombinedValidator , DefinitionsBuilder , ValidationState , Validator } ;
1413
15- fn validate_as_int ( py : Python , schema : & Bound < ' _ , PyDict > , key : & str ) -> PyResult < Option < Int > > {
16- match schema. get_as :: < Bound < ' _ , PyAny > > ( & PyString :: new ( py , key) ) ? {
14+ fn validate_as_int ( schema : & Bound < ' _ , PyDict > , key : & str ) -> PyResult < Option < Int > > {
15+ match schema. get_item ( key) ? {
1716 Some ( value) => match value. validate_int ( false ) {
1817 Ok ( v) => match v. into_inner ( ) . as_int ( ) {
1918 Ok ( v) => Ok ( Some ( v) ) ,
@@ -90,14 +89,13 @@ pub struct ConstrainedIntValidator {
9089
9190impl ConstrainedIntValidator {
9291 fn build ( schema : & Bound < ' _ , PyDict > , config : Option < & Bound < ' _ , PyDict > > ) -> PyResult < CombinedValidator > {
93- let py = schema. py ( ) ;
9492 Ok ( Self {
9593 strict : is_strict ( schema, config) ?,
96- multiple_of : validate_as_int ( py , schema, "multiple_of" ) ?,
97- le : validate_as_int ( py , schema, "le" ) ?,
98- lt : validate_as_int ( py , schema, "lt" ) ?,
99- ge : validate_as_int ( py , schema, "ge" ) ?,
100- gt : validate_as_int ( py , schema, "gt" ) ?,
94+ multiple_of : validate_as_int ( schema, "multiple_of" ) ?,
95+ le : validate_as_int ( schema, "le" ) ?,
96+ lt : validate_as_int ( schema, "lt" ) ?,
97+ ge : validate_as_int ( schema, "ge" ) ?,
98+ gt : validate_as_int ( schema, "gt" ) ?,
10199 }
102100 . into ( ) )
103101 }
0 commit comments