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: Tell users that backslashes are no longer necessary after => & | #6459

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 unecessary continuation characters in graph section.
wxtim marked this conversation as resolved.
Show resolved Hide resolved
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 `\\`'
wxtim marked this conversation as resolved.
Show resolved Hide resolved
),
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 `\\`'
wxtim marked this conversation as resolved.
Show resolved Hide resolved
),
FUNCTION: re.compile(r'[&|]\s*\\').findall
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be part of S014

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that they should in time be, but at the moment they will not work if you are using compat mode Cylc 8 and Cylc 7 in Para||el, so I think that they should be an upgrade until Cylc 7 is more dead than it currently is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"more dead" 😁

}
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
Loading