mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-09 13:18:52 +00:00
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:
parent
76148ddb76
commit
be657f5e7e
3 changed files with 33 additions and 18 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue