Respect typing_extensions imports of Annotated for B006. (#6361)

`typing_extensions.Annotated` should be treated the same way as
`typing.Annotated`.
This commit is contained in:
Zixuan Li 2023-08-05 13:39:52 -04:00 committed by GitHub
parent 76148ddb76
commit be657f5e7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 18 deletions

View file

@ -207,7 +207,7 @@ pub fn is_immutable_annotation(expr: &Expr, semantic: &SemanticModel) -> bool {
}
} else if matches!(call_path.as_slice(), ["typing", "Optional"]) {
is_immutable_annotation(slice, semantic)
} else if matches!(call_path.as_slice(), ["typing", "Annotated"]) {
} else if is_pep_593_generic_type(call_path.as_slice()) {
if let Expr::Tuple(ast::ExprTuple { elts, .. }) = slice.as_ref() {
elts.first()
.is_some_and(|elt| is_immutable_annotation(elt, semantic))