sourcery
sourcery copied to clipboard
`/=` Refactoring
Checklist
- [x] I think this refactoring is useful for everyone (if it's too specific, consider a custom rule)
- [x] Didn't find a similar issue
Description
Sourcery suggests -= and +=, however not /=.
Code Before
a = a / 2
Code After
a /= 2
Thanks for posting this - we'll add it to our backlog.
Oh hang on @Anselmoo - I do get suggested a conversion to /= as long as Sourcery can identify the type of the variable.
Have you got a code snippet where we suggest += but not /= ?
@Hellebore thx for giving me feedback. I had the issue once in a project, but unfortunately, don't find it yet.
However, I create the following four examples:
- No suggestions for refactoring
- No suggestions for refactoring
- Yes
- Shows that refactor and regular expression are the same
I hope it helps and that I don't miss anything.
https://gist.github.com/Anselmoo/f4763afb588cf0fda96255cba099c876
def cross_check() -> None:
"""Cross check with /= operator"""
i: float = 1.0
j: float = 1.0
for _ in range(10):
i = i / 2
j /= 2
print(i == j)