Skip to content

Commit

Permalink
lint - S011 no longer warns against 0{{a}} (#5841)
Browse files Browse the repository at this point in the history
lint - S011 no longer warns against 0{{a}}
  • Loading branch information
ColemanTom authored Nov 23, 2023
1 parent 04a5b18 commit b96a4d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes.d/5841.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve handling of S011 to not warn if the # is '#$' (e.g. shell base arithmetic)
2 changes: 1 addition & 1 deletion cylc/flow/scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def check_indentation(line: str) -> bool:
'evaluate commented lines': True,
FUNCTION: functools.partial(
check_if_jinja2,
function=re.compile(r'(?<!{)#.*?{[{%]').findall
function=re.compile(r'(?<!{)#[^$].*?{[{%]').findall
)
},
'S012': {
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/scripts/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ def test_check_cylc_file_jinja2_comments():
assert not any('S011' in msg for msg in lint.messages)


def test_check_cylc_file_jinja2_comments_shell_arithmetic_not_warned():
"""Jinja2 after a $((10#$variable)) should not warn"""
lint = lint_text('#!jinja2\na = b$((10#$foo+5)) {{ BAR }}', ['style'])
assert not any('S011' in msg for msg in lint.messages)


@pytest.mark.parametrize(
# 11 won't be tested because there is no jinja2 shebang
'number', set(range(1, len(MANUAL_DEPRECATIONS) + 1)) - {11}
Expand Down

0 comments on commit b96a4d0

Please sign in to comment.