Skip to content

Commit b7ec543

Browse files
authored
Correctly recognize path with spaces with tokenize (#4198)
1 parent 083ace9 commit b7ec543

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.github/workflows/tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
env:
7373
# Number of expected test passes, safety measure for accidental skip of
7474
# tests. Update value if you add/remove tests.
75-
PYTEST_REQPASS: 872
75+
PYTEST_REQPASS: 873
7676
steps:
7777
- uses: actions/checkout@v4
7878
with:

src/ansiblelint/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ def ansible_template(
220220

221221
def tokenize(value: str) -> tuple[list[str], dict[str, str]]:
222222
"""Parse a string task invocation."""
223+
# We do not try to tokenize something very simple because it would fail to
224+
# work for a case like: task_include: path with space.yml
225+
if value and "=" not in value:
226+
return ([value], {})
227+
223228
parts = split_args(value)
224229
args: list[str] = []
225230
kwargs: dict[str, str] = {}

test/test_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
{},
7575
id="x",
7676
),
77+
pytest.param(
78+
"foo bar.yml",
79+
["foo bar.yml"],
80+
{},
81+
id="path-with-spaces",
82+
),
7783
),
7884
)
7985
def test_tokenize(

0 commit comments

Comments
 (0)