diff --git a/pyupgrade/_plugins/shlex_join.py b/pyupgrade/_plugins/shlex_join.py index 14067560..1718ff9a 100644 --- a/pyupgrade/_plugins/shlex_join.py +++ b/pyupgrade/_plugins/shlex_join.py @@ -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 diff --git a/tests/features/shlex_join_test.py b/tests/features/shlex_join_test.py index fc6abe59..e3835f65 100644 --- a/tests/features/shlex_join_test.py +++ b/tests/features/shlex_join_test.py @@ -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',