Skip to content

Commit

Permalink
Merge pull request #939 from asottile/shlex-join-not-space
Browse files Browse the repository at this point in the history
only replace to shlex.join if joined with a space
  • Loading branch information
asottile committed Mar 24, 2024
2 parents 3e4103f + d560e38 commit 9a0cad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/shlex_join.py
Expand Up @@ -39,7 +39,7 @@ def visit_Call(
if (
isinstance(node.func, ast.Attribute) and
isinstance(node.func.value, ast.Constant) and
isinstance(node.func.value.value, str) and
node.func.value.value == ' ' and
node.func.attr == 'join' and
not node.keywords and
len(node.args) == 1 and
Expand Down
6 changes: 6 additions & 0 deletions tests/features/shlex_join_test.py
Expand Up @@ -15,6 +15,12 @@
(3, 8),
id='quote from-imported',
),
pytest.param(
'import shlex\n'
'"wat".join(shlex.quote(arg) for arg in cmd)\n',
(3, 8),
id='not joined with space',
),
pytest.param(
'import shlex\n'
'" ".join(shlex.quote(arg) for arg in cmd)\n',
Expand Down

0 comments on commit 9a0cad2

Please sign in to comment.