asottile / pyupgrade

A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.
MIT License
3.5k stars 177 forks source link

multi-line exception with duplicate BaseException and comments gives invalid code #932

Closed jakkdl closed 6 months ago

jakkdl commented 7 months ago

before

try:
    ...
except (
    BaseException,
    BaseException # b
):
    ...

after

try:
    ...
except (BaseException, BaseException # b):
    ...

info

I expect you never intend to output invalid code, and similar errors could probably pop up in normal usage. I don't have much of an opinion on whether pyupgrade does nothing, or actually manages to remove the BaseException and move the comment somewhere else.