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:
Charlie Marsh 2023-11-07 14:27:58 -08:00 committed by GitHub
parent e2c7b1ece6
commit 71e93a9fa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 6 deletions

View file

@ -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 {