Open dscorbett opened 3 months ago
I would vote against changing this... The same could be said for attribute accesses, and we don't include those. I would say that rules that rely on detecting effects should have unsafe fixes, in general, instead of taking away user access to the fixes entirely.
Some expressions, like literals, definitely don’t have side effects, so their fixes needn’t be marked unsafe. contains_effect
could have three return values, indicating the availability of safe fixes (definitely no side effect), unsafe fixes (maybe a side effect, but probably not), and no fixes (probably a side effect).
contains_effect
should consider f-strings to have effects because of the implicit__str__
or__repr__
call. This affects any rule that relies oncontains_effect
; here is an example with RUF019.Some f-strings can be statically proven to not have effects, if they contain no formatted expressions (
f"x"
) or they only format values of types formatting which is known not to have effects (f"{1}"
).