Skip to content

Commit

Permalink
Rename Self to concrete type in method
Browse files Browse the repository at this point in the history
As without editor support it might be hard to figure out what the
concrete type is
  • Loading branch information
dhruvmanila committed Jun 9, 2023
1 parent da5f248 commit 6cc392a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions crates/ruff/src/rules/ruff/rules/implicit_optional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,34 +183,34 @@ impl<'a> TypingTarget<'a> {
/// Check if the [`TypingTarget`] explicitly allows `None`.
fn contains_none(&self, model: &SemanticModel) -> bool {
match self {
Self::None | Self::Optional | Self::Any => true,
Self::Literal(elements) => elements.iter().any(|element| {
let Some(new_target) = Self::try_from_expr(model, element) else {
TypingTarget::None | TypingTarget::Optional | TypingTarget::Any => true,
TypingTarget::Literal(elements) => elements.iter().any(|element| {
let Some(new_target) = TypingTarget::try_from_expr(model, element) else {
return false;
};
// Literal can only contain `None`, a literal value, other `Literal`
// or an enum value.
match new_target {
Self::None => true,
Self::Literal(_) => new_target.contains_none(model),
TypingTarget::None => true,
TypingTarget::Literal(_) => new_target.contains_none(model),
_ => false,
}
}),
Self::Union(elements) => elements.iter().any(|element| {
let Some(new_target) = Self::try_from_expr(model, element) else {
TypingTarget::Union(elements) => elements.iter().any(|element| {
let Some(new_target) = TypingTarget::try_from_expr(model, element) else {
return false;
};
match new_target {
Self::None => true,
TypingTarget::None => true,
_ => new_target.contains_none(model),
}
}),
Self::Annotated(element) => {
let Some(new_target) = Self::try_from_expr(model, element) else {
TypingTarget::Annotated(element) => {
let Some(new_target) = TypingTarget::try_from_expr(model, element) else {
return false;
};
match new_target {
Self::None => true,
TypingTarget::None => true,
_ => new_target.contains_none(model),
}
}
Expand Down

0 comments on commit 6cc392a

Please sign in to comment.