mhammond / pywin32

Python for Windows (pywin32) Extensions
4.9k stars 783 forks source link

Using augmented assignements (in-place operators) where possible #2274

Closed Avasam closed 3 weeks ago

Avasam commented 4 weeks ago

Most were found thanks to https://docs.astral.sh/ruff/rules/non-augmented-assignment/

Then, since Ruff/PLR6104 doesn't support associative operations (yet https://github.com/astral-sh/ruff/issues/11656), I used the following regex to find more: (\w+?) = (\(\n\s+)\1 ([\+\-\*/\|&%~]|>>|<<|\*\*|//) --> $1 $3= ( (\w+?) = \1 ([\+\-\*/\|&%~]|>>|<<|\*\*|//) --> $1 $2= (\w+?) = f('|")\{\1\} --> $1 += f$2

Then manually reviewed the whole thing.