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

cylc lint: S015/U017 line continuation chars #6493

Merged
merged 4 commits into from
Nov 26, 2024
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/6459.feat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`cylc lint` now checks for unnecessary continuation characters in the graph section.
14 changes: 13 additions & 1 deletion cylc/flow/scripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,13 @@ def list_wrapper(line: str, check: Callable) -> Optional[Dict[str, str]]:
for job_runner, directive in WALLCLOCK_DIRECTIVES.items()
)),
FUNCTION: check_wallclock_directives,
}
},
'S015': {
'short': (
'`=>` implies 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 @@ -785,6 +791,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 `|` imply line continuation 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 @@ -45,7 +45,7 @@
STYLE_CHECKS = parse_checks(['style'])
UPG_CHECKS = parse_checks(['728'])

TEST_FILE = """
TEST_FILE = '''
[visualization]

[cylc]
Expand Down Expand Up @@ -98,7 +98,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 @@ -155,10 +161,10 @@
host = `rose host-select thingy`

%include foo.cylc
"""
'''


LINT_TEST_FILE = """
LINT_TEST_FILE = '''
\t[scheduler]

[scheduler]
Expand All @@ -168,6 +174,11 @@
{% foo %}
{{foo}}
# {{quix}}
R1 = """
foo & \\
bar => \\
baz
"""

[runtime]
[[this_is_ok]]
Expand All @@ -183,7 +194,7 @@
-l walltime = 666
[[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
Loading