Fix F821 false positive (#911)

This commit is contained in:
Jonathan Plasse
2022-11-26 16:12:07 +01:00
committed by GitHub
parent 560558b814
commit 9edc479c6c
4 changed files with 30 additions and 9 deletions

View File

@@ -209,15 +209,21 @@ pub enum SubscriptKind {
PEP593AnnotatedSubscript,
}
pub fn match_annotated_subscript(
pub fn match_annotated_subscript<F>(
expr: &Expr,
from_imports: &FxHashMap<&str, FxHashSet<&str>>,
import_aliases: &FxHashMap<&str, &str>,
) -> Option<SubscriptKind> {
is_builtin: F,
) -> Option<SubscriptKind>
where
F: Fn(&str) -> bool,
{
let call_path = dealias_call_path(collect_call_paths(expr), import_aliases);
if !call_path.is_empty() {
for (module, member) in SUBSCRIPTS {
if match_call_path(&call_path, module, member, from_imports) {
if match_call_path(&call_path, module, member, from_imports)
&& (!module.is_empty() || is_builtin(member))
{
return Some(SubscriptKind::AnnotatedSubscript);
}
}