Skip to content

Commit 9222ef8

Browse files
authored
fix clippy::manual_let_else lint (#1830)
1 parent 67cf14a commit 9222ef8

File tree

6 files changed

+10
-19
lines changed

6 files changed

+10
-19
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ doc_markdown = "allow"
9090
float_cmp = "allow"
9191
fn_params_excessive_bools = "allow"
9292
if_not_else = "allow"
93-
manual_let_else = "allow"
9493
match_bool = "allow"
9594
match_same_arms = "allow"
9695
missing_errors_doc = "allow"

src/lookup_key.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ impl LookupKey {
5959
}
6060
} else {
6161
let list = value.downcast::<PyList>()?;
62-
let first = match list.get_item(0) {
63-
Ok(v) => v,
64-
Err(_) => return py_schema_err!("Lookup paths should have at least one element"),
62+
let Ok(first) = list.get_item(0) else {
63+
return py_schema_err!("Lookup paths should have at least one element");
6564
};
6665
let mut locs: Vec<LookupPath> = if first.downcast::<PyString>().is_ok() {
6766
// list of strings rather than list of lists

src/serializers/fields.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,7 @@ impl TypeSerializer for GeneralFieldsSerializer {
366366
// If there is no model, we (a TypedDict) are the model
367367
let model = extra.model.map_or_else(|| Some(value), Some);
368368

369-
let (main_dict, extra_dict) = if let Some(main_extra_dict) = self.extract_dicts(value) {
370-
main_extra_dict
371-
} else {
369+
let Some((main_dict, extra_dict)) = self.extract_dicts(value) else {
372370
extra.warnings.on_fallback_py(self.get_name(), value, extra)?;
373371
return infer_to_python(value, include, exclude, extra);
374372
};
@@ -412,9 +410,7 @@ impl TypeSerializer for GeneralFieldsSerializer {
412410
exclude: Option<&Bound<'_, PyAny>>,
413411
extra: &Extra,
414412
) -> Result<S::Ok, S::Error> {
415-
let (main_dict, extra_dict) = if let Some(main_extra_dict) = self.extract_dicts(value) {
416-
main_extra_dict
417-
} else {
413+
let Some((main_dict, extra_dict)) = self.extract_dicts(value) else {
418414
extra.warnings.on_fallback_ser::<S>(self.get_name(), value, extra)?;
419415
return infer_serialize(value, serializer, include, exclude, extra);
420416
};

src/serializers/type_serializers/tuple.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,8 @@ impl TupleSerializer {
187187
macro_rules! use_serializers {
188188
($serializers_iter:expr) => {
189189
for (index, serializer) in $serializers_iter.enumerate() {
190-
let element = match py_tuple_iter.next() {
191-
Some(value) => value,
192-
None => break,
190+
let Some(element) = py_tuple_iter.next() else {
191+
break;
193192
};
194193
let op_next = self.filter.index_filter(index, include, exclude, Some(n_items))?;
195194
if let Some((next_include, next_exclude)) = op_next {

src/validators/datetime.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,8 @@ impl TZConstraint {
302302

303303
pub(super) fn from_py(schema: &Bound<'_, PyDict>) -> PyResult<Option<Self>> {
304304
let py = schema.py();
305-
let tz_constraint = match schema.get_item(intern!(py, "tz_constraint"))? {
306-
Some(c) => c,
307-
None => return Ok(None),
305+
let Some(tz_constraint) = schema.get_item(intern!(py, "tz_constraint"))? else {
306+
return Ok(None);
308307
};
309308
if let Ok(s) = tz_constraint.downcast::<PyString>() {
310309
let s = s.to_str()?;

src/validators/union.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,8 @@ impl Validator for TaggedUnionValidator {
357357
let dict = input.validate_model_fields(state.strict_or(false), from_attributes)?;
358358
// note this methods returns PyResult<Option<(data, data)>>, the outer Err is just for
359359
// errors when getting attributes which should be "raised"
360-
let tag = match dict.get_item(lookup_key)? {
361-
Some((_, value)) => value,
362-
None => return Err(self.tag_not_found(input)),
360+
let Some((_, tag)) = dict.get_item(lookup_key)? else {
361+
return Err(self.tag_not_found(input));
363362
};
364363
self.find_call_validator(py, &tag.borrow_input().to_object(py)?, input, state)
365364
}

0 commit comments

Comments
 (0)