Skip to content

Commit

Permalink
Lint: Tell users that backslashes are no longer necessary after => & |
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Nov 5, 2024
1 parent ddf5349 commit 6f7c711
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
14 changes: 13 additions & 1 deletion cylc/flow/scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,13 @@ def list_wrapper(line: str, check: Callable) -> Optional[Dict[str, str]]:
'S013': {
'short': 'Items should be indented in 4 space blocks.',
FUNCTION: check_indentation
}
},
'S014': {
'short': (
'`=>` is a line continuation without `\\`'
),
FUNCTION: re.compile(r'=>\s*\\').findall
},
}
# Subset of deprecations which are tricky (impossible?) to scrape from the
# upgrader.
Expand Down Expand Up @@ -715,6 +721,12 @@ def list_wrapper(line: str, check: Callable) -> Optional[Dict[str, str]]:
FUNCTION: functools.partial(
list_wrapper, check=CHECK_FOR_OLD_VARS.findall),
},
'U017': {
'short': (
'`&` and `|` are line continuations without `\\`'
),
FUNCTION: re.compile(r'[&|]\s*\\').findall
},
}
ALL_RULESETS = ['728', 'style', 'all']
EXTRA_TOML_VALIDATION = {
Expand Down
21 changes: 16 additions & 5 deletions tests/unit/scripts/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
STYLE_CHECKS = parse_checks(['style'])
UPG_CHECKS = parse_checks(['728'])

TEST_FILE = """
TEST_FILE = '''
[visualization]
[cylc]
Expand Down Expand Up @@ -97,7 +97,13 @@
hold after point = 20220101T0000Z
[[dependencies]]
[[[R1]]]
graph = MyFaM:finish-all => remote => !mash_theme
graph = """
MyFaM:finish-all => remote => !mash_theme
a & \\
b => c
c | \\
d => e
"""
[runtime]
[[root]]
Expand Down Expand Up @@ -154,10 +160,10 @@
host = `rose host-select thingy`
%include foo.cylc
"""
'''


LINT_TEST_FILE = """
LINT_TEST_FILE = '''
\t[scheduler]
[scheduler]
Expand All @@ -167,6 +173,11 @@
{% foo %}
{{foo}}
# {{quix}}
R1 = """
foo & \\
bar => \\
baz
"""
[runtime]
[[this_is_ok]]
Expand All @@ -180,7 +191,7 @@
platform = $(some-script foo)
[[baz]]
platform = `no backticks`
""" + (
''' + (
'\nscript = the quick brown fox jumps over the lazy dog until it becomes '
'clear that this line is longer than the default 130 character limit.'
)
Expand Down

0 comments on commit 6f7c711

Please sign in to comment.