mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:47 +00:00
Narrowing for class patterns in match statements (#15223)
We now support class patterns in a match statement, adding a narrowing constraint that within the body of that match arm, we can assume that the subject is an instance of that class. --------- Co-authored-by: Carl Meyer <carl@astral.sh> Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
f2a86fcfda
commit
b2a0d68d70
6 changed files with 151 additions and 43 deletions
|
@ -329,9 +329,9 @@ impl<'db> VisibilityConstraints<'db> {
|
|||
Truthiness::Ambiguous
|
||||
}
|
||||
}
|
||||
PatternConstraintKind::Singleton(..) | PatternConstraintKind::Unsupported => {
|
||||
Truthiness::Ambiguous
|
||||
}
|
||||
PatternConstraintKind::Singleton(..)
|
||||
| PatternConstraintKind::Class(..)
|
||||
| PatternConstraintKind::Unsupported => Truthiness::Ambiguous,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue