mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Only flag flake8-trio rule when trio is present (#8550)
## Summary Hoping to avoid some false positives by narrowing the scope of https://github.com/astral-sh/ruff/pull/8534.
This commit is contained in:
parent
e2c7b1ece6
commit
71e93a9fa4
4 changed files with 30 additions and 6 deletions
|
@ -1207,6 +1207,16 @@ impl<'a> SemanticModel<'a> {
|
|||
exceptions
|
||||
}
|
||||
|
||||
/// Return `true` if the module at the given path was seen anywhere in the semantic model.
|
||||
/// This includes both direct imports (`import trio`) and member imports (`from trio import
|
||||
/// TrioTask`).
|
||||
pub fn seen(&self, module: &[&str]) -> bool {
|
||||
self.bindings
|
||||
.iter()
|
||||
.filter_map(Binding::as_any_import)
|
||||
.any(|import| import.call_path().starts_with(module))
|
||||
}
|
||||
|
||||
/// Generate a [`Snapshot`] of the current semantic model.
|
||||
pub fn snapshot(&self) -> Snapshot {
|
||||
Snapshot {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue