Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint - S011 no longer warns against 0{{a}} #5841

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -334,6 +334,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