Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/serializers/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ impl TypeSerializer for GeneralFieldsSerializer {
map.end()
}

fn get_name(&self) -> &str {
fn get_name(&self) -> &'static str {
"general-fields"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/serializers/type_serializers/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl TypeSerializer for ComplexSerializer {
}
}

fn get_name(&self) -> &str {
fn get_name(&self) -> &'static str {
"complex"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/serializers/type_serializers/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl FunctionPlainSerializer {
fn retry_with_lax_check(&self) -> bool {
self.fallback_serializer
.as_ref()
.map_or(false, |f| f.retry_with_lax_check())
.is_some_and(|f| f.retry_with_lax_check())
|| self.return_serializer.retry_with_lax_check()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/validators/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Validator for BytesConstrainedValidator {
Ok(either_bytes.into_py_any(py)?)
}

fn get_name(&self) -> &str {
fn get_name(&self) -> &'static str {
"constrained-bytes"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/validators/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Validator for ComplexValidator {
Ok(res.into_pyobject(py)?.into())
}

fn get_name(&self) -> &str {
fn get_name(&self) -> &'static str {
"complex"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/validators/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl Validator for ConstrainedFloatValidator {
Ok(either_float.into_py_any(py)?)
}

fn get_name(&self) -> &str {
fn get_name(&self) -> &'static str {
"constrained-float"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/validators/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl Validator for ConstrainedIntValidator {
Ok(either_int.into_py_any(py)?)
}

fn get_name(&self) -> &str {
fn get_name(&self) -> &'static str {
"constrained-int"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/validators/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Validator for StrConstrainedValidator {
Ok(py_string.into_py_any(py)?)
}

fn get_name(&self) -> &str {
fn get_name(&self) -> &'static str {
"constrained-str"
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/validators/typed_dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,7 @@ impl Validator for TypedDictValidator {
ExtraBehavior::Allow => {
let py_key = either_str.as_py_string(self.py, self.state.cache_str());
if let Some(validator) = self.extras_validator {
let last_partial = self.partial_last_key.as_ref().map_or(false, |last_key| {
let key_loc: LocItem = raw_key.clone().into();
&key_loc == last_key
});
let last_partial = self.partial_last_key.as_ref() == Some(&raw_key.clone().into());
self.state.allow_partial = match last_partial {
true => self.allow_partial,
false => false.into(),
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmarks/nested_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def schema_using_defs() -> cs.CoreSchema:
'fields': {
str(c): {
'type': 'model-field',
'schema': {'type': 'definition-ref', 'schema_ref': f'model_{level+1}'},
'schema': {'type': 'definition-ref', 'schema_ref': f'model_{level + 1}'},
}
for c in range(N)
},
Expand Down
2 changes: 1 addition & 1 deletion tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def test_json_bytes_base64_invalid():
{
'type': 'bytes_invalid_encoding',
'loc': (),
'msg': f'Data should be valid base64: Invalid symbol {ord("!")}, offset {len(wrong_input)-1}.',
'msg': f'Data should be valid base64: Invalid symbol {ord("!")}, offset {len(wrong_input) - 1}.',
'input': wrong_input,
}
]
Expand Down
5 changes: 1 addition & 4 deletions tests/validators/test_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,7 @@ def test_int_strict(py_and_json: PyAndJson, input_value, expected):
(
{'ge': 0},
-1,
Err(
'Input should be greater than or equal to 0 '
'[type=greater_than_equal, input_value=-1, input_type=int]'
),
Err('Input should be greater than or equal to 0 [type=greater_than_equal, input_value=-1, input_type=int]'),
),
({'gt': 0}, 1, 1),
({'gt': 0}, 0, Err('Input should be greater than 0 [type=greater_than, input_value=0, input_type=int]')),
Expand Down
3 changes: 1 addition & 2 deletions tests/validators/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ def test_any(py_and_json: PyAndJson, input_value, expected):
pytest.param(
'xx',
Err(
'Invalid JSON: expected value at line 1 column 1 '
"[type=json_invalid, input_value='xx', input_type=str]"
"Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='xx', input_type=str]"
),
id='str_invalid',
),
Expand Down
6 changes: 1 addition & 5 deletions tests/validators/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,7 @@ def test_invalid_regex(engine):

if engine is None or engine == 'rust-regex':
assert exc_info.value.args[0] == (
'Error building "str" validator:\n'
' SchemaError: regex parse error:\n'
' (abc\n'
' ^\n'
'error: unclosed group'
'Error building "str" validator:\n SchemaError: regex parse error:\n (abc\n ^\nerror: unclosed group'
)
elif engine == 'python-re':
prefix = 'PatternError' if sys.version_info >= (3, 13) else 'error'
Expand Down
Loading