Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Redoubts opened this issue Mar 18, 2024 · 1 comment · Fixed by #939
Closed

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

Redoubts opened this issue Mar 18, 2024 · 1 comment · Fixed by #939

Comments

@Redoubts
Copy link

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants