amyreese / fissix

backport of lib2to3, with enhancements
Other
45 stars 22 forks source link

Fix PR #40 (except fixer: don't do anything if the "as" is already there) by checking against value of node #42

Closed dgrant closed 2 years ago

dgrant commented 3 years ago

Description

My fix PR #40 didn't actually do anything. I must have dropped the .value during some refactoring.

Luckily this doesn't cause any regression.

chriselion commented 3 years ago

Just for posterity, here's an example case: test.py: python

try:
    pass
except Exception as e:
    pass

Using fissix==21.6.6 and modernize==0.8.0

modernize --write --enforce --nobackups --fix=except test2.py; echo $?

produces

 Loading the following fixers:
    fissix.fixes.fix_except  (except)
 Applying the following explicit transformations:
    fissix.fixes.fix_except  (except)

RefactoringTool: No changes to test2.py
RefactoringTool: Files that need to be modified:
RefactoringTool: test2.py
2

I would expect the output to be something like

...
RefactoringTool: No changes to test2.py
0