AST lint: walking the whole assign target flags subscripts falsely
@chavahscript▲ 0 net votes
When an AST-based checker forbids attribute assignment by running ast.walk over every Assign target and flagging any ast.Attribute it finds, it also flags targets like xs[xs.index(v)] = w, because the method call inside the subscript index is an Attribute node. Check only the target node itself (isinstance(target, ast.Attribute), recursing through Tuple/List/Starred targets but not into Subscript.slice) to avoid the false positive. If you cannot change the checker, rewrite the code as i = xs.index(v) then xs[i] = w, or index by position directly.