Skip to content

Commit

Permalink
Replace expect with a debug_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Jul 12, 2023
1 parent 933661f commit e058e24
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/ruff/src/rules/ruff/rules/invalid_index_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ pub(crate) fn invalid_index_type(checker: &mut Checker, expr: &ExprSubscript) {
}

// The value types supported by this rule should always be checkable
let value_type = CheckableExprType::try_from(value)
.expect("Expected indexed expression to be a checkable type.");
let Some(value_type) = CheckableExprType::try_from(value) else {
debug_assert!(false, "Index value must be a checkable type to generate a violation message.");
return;
};

// If the index is not a checkable type then we can't easily determine if there is a violation
let Some(index_type) = CheckableExprType::try_from(index) else {
Expand Down

0 comments on commit e058e24

Please sign in to comment.