Skip to content

Commit 092be01

Browse files
committed
fix: apply feedback
1 parent 3180d8d commit 092be01

File tree

6 files changed

+5
-7
lines changed

6 files changed

+5
-7
lines changed

pydantic_core/core_schema.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3802,7 +3802,6 @@ def definition_reference_schema(
38023802
'int_from_float',
38033803
'float_type',
38043804
'float_parsing',
3805-
'float_parsing_size',
38063805
'bytes_type',
38073806
'bytes_too_short',
38083807
'bytes_too_long',

src/errors/types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ pub enum ErrorType {
181181
// float errors
182182
FloatType,
183183
FloatParsing,
184-
FloatParsingSize,
185184
// ---------------------
186185
// bytes errors
187186
BytesType,
@@ -503,7 +502,6 @@ impl ErrorType {
503502
Self::IntParsingSize => "Unable to parse input string as an integer, exceeded maximum size",
504503
Self::FloatType => "Input should be a valid number",
505504
Self::FloatParsing => "Input should be a valid number, unable to parse string as a number",
506-
Self::FloatParsingSize => "Unable to parse input string as a number, exceeded maximum size",
507505
Self::BytesType => "Input should be a valid bytes",
508506
Self::BytesTooShort {..} => "Data should have at least {min_length} bytes",
509507
Self::BytesTooLong {..} => "Data should have at most {max_length} bytes",

src/input/input_python.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ impl<'a> Input<'a> for PyAny {
305305
fn ultra_strict_float(&'a self) -> ValResult<EitherFloat<'a>> {
306306
if self.is_instance_of::<PyInt>() {
307307
Err(ValError::new(ErrorType::FloatType, self))
308-
} else if let Ok(float) = self.extract::<f64>() {
309-
Ok(EitherFloat::F64(float))
308+
} else if self.is_instance_of::<PyFloat>() {
309+
Ok(EitherFloat::Py(self))
310310
} else {
311311
Err(ValError::new(ErrorType::FloatType, self))
312312
}

src/input/return_enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ impl<'a> TryInto<f64> for EitherFloat<'a> {
905905
fn try_into(self) -> ValResult<'a, f64> {
906906
match self {
907907
EitherFloat::F64(f) => Ok(f),
908-
EitherFloat::Py(i) => i.extract().map_err(|_| ValError::new(ErrorType::FloatParsingSize, i)),
908+
EitherFloat::Py(i) => i.extract().map_err(|_| ValError::new(ErrorType::FloatParsing, i)),
909909
}
910910
}
911911
}

tests/test_errors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ def f(input_value, info):
233233
('less_than_equal', 'Input should be less than or equal to 42.1', {'le': 42.1}),
234234
('float_type', 'Input should be a valid number', None),
235235
('float_parsing', 'Input should be a valid number, unable to parse string as a number', None),
236-
('float_parsing_size', 'Unable to parse input string as a number, exceeded maximum size', None),
237236
('bytes_type', 'Input should be a valid bytes', None),
238237
('bytes_too_short', 'Data should have at least 42 bytes', {'min_length': 42}),
239238
('bytes_too_long', 'Data should have at most 42 bytes', {'max_length': 42}),

tests/validators/test_float.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from ..conftest import Err, PyAndJson, plain_repr
1212

13+
f64_max = 1.7976931348623157e308
14+
1315

1416
@pytest.mark.parametrize(
1517
'input_value,expected',

0 commit comments

Comments
 (0)