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

"".join(shlex.quote(...) ...) to shlex.join(...) is too eager #936

Closed Redoubts closed 5 months ago

Redoubts commented 5 months ago

Consider the following:

import shlex

trash_bin = "garbage".join(shlex.quote(a) for a in ["some", "quotable strings"])

If I run pyupgrade --py310-plus on this, I get trash_bin = shlex.join(["some", "quotable strings"]). But this is not equivalent. This is a very contrived case, but there are real cases I could envision, like ", ", where one might want to keep the str.join

pyupgrade==3.15.1

asottile commented 5 months ago

good catch! looks like this missed a check on the actual join string