mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 20:42:10 +00:00
[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:
parent
1f303a5eb6
commit
e3d792605f
4 changed files with 104 additions and 77 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue