Skip to content

Commit

Permalink
jinja[spacing] Ensure ~ is correctly spaced
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Aug 24, 2022
1 parent ec7599c commit bcf0667
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:TOX_PARALLEL_NO_SPINNER
# Number of expected test passes, safety measure for accidental skip of
# tests. Update value if you add/remove tests.
PYTEST_REQPASS: 696
PYTEST_REQPASS: 697

steps:
- name: Activate WSL1
Expand Down
6 changes: 5 additions & 1 deletion src/ansiblelint/rules/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ def in_expression(tokens: list[Any]) -> str:
elif tokens[-2][2] != "," and in_expression(tokens) == "[":
tokens.pop()
else:
if tokens[-2][1] == "operator" and tokens[-2][2] in ("-", "+"):
if (
tokens[-2][1] == "operator"
and tokens[-2][2] in spaced_operators
):
avoid_spacing = False
for token in tokens[:-2][::-1]:
if token[1] in begin_types:
Expand Down Expand Up @@ -539,6 +542,7 @@ def test_jinja_spacing_vars() -> None:
"spacing",
id="35",
),
pytest.param("{{ a ~'b' }}", "{{ a ~ 'b' }}", "spacing", id="36"),
),
)
def test_jinja(text: str, expected: str, tag: str) -> None:
Expand Down

0 comments on commit bcf0667

Please sign in to comment.