[flake8-bugbear] Fix mutable-contextvar-default (B039) to resolve annotated function calls properly (#14532)

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

Fix #14525

## Test Plan

<!-- How was it tested? -->

New test cases

---------

Signed-off-by: harupy <hkawamura0130@gmail.com>
This commit is contained in:
Harutaka Kawamura 2024-11-24 11:29:25 +09:00 committed by GitHub
parent 1f303a5eb6
commit e3d792605f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 104 additions and 77 deletions

View file

@ -279,7 +279,7 @@ pub fn is_immutable_func(
extend_immutable_calls: &[QualifiedName],
) -> bool {
semantic
.resolve_qualified_name(func)
.resolve_qualified_name(map_subscript(func))
.is_some_and(|qualified_name| {
is_immutable_return_type(qualified_name.segments())
|| extend_immutable_calls
@ -306,7 +306,7 @@ pub fn is_mutable_expr(expr: &Expr, semantic: &SemanticModel) -> bool {
| Expr::ListComp(_)
| Expr::DictComp(_)
| Expr::SetComp(_) => true,
Expr::Call(ast::ExprCall { func, .. }) => is_mutable_func(func, semantic),
Expr::Call(ast::ExprCall { func, .. }) => is_mutable_func(map_subscript(func), semantic),
_ => false,
}
}