mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 20:42:10 +00:00
[ruff
] Avoid emitting assignment-in-assert
when all references to the assigned variable are themselves inside assert
s (RUF018
) (#14661)
This commit is contained in:
parent
b63c2e126b
commit
f3d8c023d3
9 changed files with 106 additions and 15 deletions
|
@ -93,6 +93,11 @@ impl ResolvedReference {
|
|||
self.flags
|
||||
.intersects(SemanticModelFlags::ANNOTATED_TYPE_ALIAS)
|
||||
}
|
||||
|
||||
/// Return `true` if the context is inside an `assert` statement
|
||||
pub const fn in_assert_statement(&self) -> bool {
|
||||
self.flags.intersects(SemanticModelFlags::ASSERT_STATEMENT)
|
||||
}
|
||||
}
|
||||
|
||||
impl Ranged for ResolvedReference {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue