Skip to content

Commit b96a4d0

Browse files
authored
lint - S011 no longer warns against 0{{a}} (#5841)
lint - S011 no longer warns against 0{{a}}
1 parent 04a5b18 commit b96a4d0

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

changes.d/5841.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve handling of S011 to not warn if the # is '#$' (e.g. shell base arithmetic)

cylc/flow/scripts/lint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def check_indentation(line: str) -> bool:
437437
'evaluate commented lines': True,
438438
FUNCTION: functools.partial(
439439
check_if_jinja2,
440-
function=re.compile(r'(?<!{)#.*?{[{%]').findall
440+
function=re.compile(r'(?<!{)#[^$].*?{[{%]').findall
441441
)
442442
},
443443
'S012': {

tests/unit/scripts/test_lint.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ def test_check_cylc_file_jinja2_comments():
335335
assert not any('S011' in msg for msg in lint.messages)
336336

337337

338+
def test_check_cylc_file_jinja2_comments_shell_arithmetic_not_warned():
339+
"""Jinja2 after a $((10#$variable)) should not warn"""
340+
lint = lint_text('#!jinja2\na = b$((10#$foo+5)) {{ BAR }}', ['style'])
341+
assert not any('S011' in msg for msg in lint.messages)
342+
343+
338344
@pytest.mark.parametrize(
339345
# 11 won't be tested because there is no jinja2 shebang
340346
'number', set(range(1, len(MANUAL_DEPRECATIONS) + 1)) - {11}

0 commit comments

Comments
 (0)