Skip to content

Commit 9a0cad2

Browse files
authored
Merge pull request #939 from asottile/shlex-join-not-space
only replace to shlex.join if joined with a space
2 parents 3e4103f + d560e38 commit 9a0cad2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pyupgrade/_plugins/shlex_join.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def visit_Call(
3939
if (
4040
isinstance(node.func, ast.Attribute) and
4141
isinstance(node.func.value, ast.Constant) and
42-
isinstance(node.func.value.value, str) and
42+
node.func.value.value == ' ' and
4343
node.func.attr == 'join' and
4444
not node.keywords and
4545
len(node.args) == 1 and

tests/features/shlex_join_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
(3, 8),
1616
id='quote from-imported',
1717
),
18+
pytest.param(
19+
'import shlex\n'
20+
'"wat".join(shlex.quote(arg) for arg in cmd)\n',
21+
(3, 8),
22+
id='not joined with space',
23+
),
1824
pytest.param(
1925
'import shlex\n'
2026
'" ".join(shlex.quote(arg) for arg in cmd)\n',

0 commit comments

Comments
 (0)