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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ doc_markdown = "allow"
float_cmp = "allow"
fn_params_excessive_bools = "allow"
if_not_else = "allow"
manual_let_else = "allow"
match_bool = "allow"
match_same_arms = "allow"
missing_errors_doc = "allow"
Expand Down
5 changes: 2 additions & 3 deletions src/lookup_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ impl LookupKey {
}
} else {
let list = value.downcast::<PyList>()?;
let first = match list.get_item(0) {
Ok(v) => v,
Err(_) => return py_schema_err!("Lookup paths should have at least one element"),
let Ok(first) = list.get_item(0) else {
return py_schema_err!("Lookup paths should have at least one element");
};
let mut locs: Vec<LookupPath> = if first.downcast::<PyString>().is_ok() {
// list of strings rather than list of lists
Expand Down
8 changes: 2 additions & 6 deletions src/serializers/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ impl TypeSerializer for GeneralFieldsSerializer {
// If there is no model, we (a TypedDict) are the model
let model = extra.model.map_or_else(|| Some(value), Some);

let (main_dict, extra_dict) = if let Some(main_extra_dict) = self.extract_dicts(value) {
main_extra_dict
} else {
let Some((main_dict, extra_dict)) = self.extract_dicts(value) else {
extra.warnings.on_fallback_py(self.get_name(), value, extra)?;
return infer_to_python(value, include, exclude, extra);
};
Expand Down Expand Up @@ -412,9 +410,7 @@ impl TypeSerializer for GeneralFieldsSerializer {
exclude: Option<&Bound<'_, PyAny>>,
extra: &Extra,
) -> Result<S::Ok, S::Error> {
let (main_dict, extra_dict) = if let Some(main_extra_dict) = self.extract_dicts(value) {
main_extra_dict
} else {
let Some((main_dict, extra_dict)) = self.extract_dicts(value) else {
extra.warnings.on_fallback_ser::<S>(self.get_name(), value, extra)?;
return infer_serialize(value, serializer, include, exclude, extra);
};
Expand Down
5 changes: 2 additions & 3 deletions src/serializers/type_serializers/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,8 @@ impl TupleSerializer {
macro_rules! use_serializers {
($serializers_iter:expr) => {
for (index, serializer) in $serializers_iter.enumerate() {
let element = match py_tuple_iter.next() {
Some(value) => value,
None => break,
let Some(element) = py_tuple_iter.next() else {
break;
};
let op_next = self.filter.index_filter(index, include, exclude, Some(n_items))?;
if let Some((next_include, next_exclude)) = op_next {
Expand Down
5 changes: 2 additions & 3 deletions src/validators/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,8 @@ impl TZConstraint {

pub(super) fn from_py(schema: &Bound<'_, PyDict>) -> PyResult<Option<Self>> {
let py = schema.py();
let tz_constraint = match schema.get_item(intern!(py, "tz_constraint"))? {
Some(c) => c,
None => return Ok(None),
let Some(tz_constraint) = schema.get_item(intern!(py, "tz_constraint"))? else {
return Ok(None);
};
if let Ok(s) = tz_constraint.downcast::<PyString>() {
let s = s.to_str()?;
Expand Down
5 changes: 2 additions & 3 deletions src/validators/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,8 @@ impl Validator for TaggedUnionValidator {
let dict = input.validate_model_fields(state.strict_or(false), from_attributes)?;
// note this methods returns PyResult<Option<(data, data)>>, the outer Err is just for
// errors when getting attributes which should be "raised"
let tag = match dict.get_item(lookup_key)? {
Some((_, value)) => value,
None => return Err(self.tag_not_found(input)),
let Some((_, tag)) = dict.get_item(lookup_key)? else {
return Err(self.tag_not_found(input));
};
self.find_call_validator(py, &tag.borrow_input().to_object(py)?, input, state)
}
Expand Down
Loading