From 5c65514a1c1109b9bf75ea47b8ea182b75da65f1 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:41:23 +0000 Subject: [PATCH 1/4] Lint: Tell users that backslashes are no longer necessary after => & | --- changes.d/6459.feat.md | 1 + cylc/flow/scripts/lint.py | 14 +++++++++++++- tests/unit/scripts/test_lint.py | 21 ++++++++++++++++----- 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 changes.d/6459.feat.md diff --git a/changes.d/6459.feat.md b/changes.d/6459.feat.md new file mode 100644 index 0000000000..19fddbbd10 --- /dev/null +++ b/changes.d/6459.feat.md @@ -0,0 +1 @@ +Cylc lint now checks for unecessary continuation characters in graph section. diff --git a/cylc/flow/scripts/lint.py b/cylc/flow/scripts/lint.py index cf9705232d..d26787148c 100755 --- a/cylc/flow/scripts/lint.py +++ b/cylc/flow/scripts/lint.py @@ -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': ( + '`=>` is a line continuation without `\\`.' + ), + FUNCTION: re.compile(r'=>\s*\\').findall + }, } # Subset of deprecations which are tricky (impossible?) to scrape from the # upgrader. @@ -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 `|` are line continuations without `\\`' + ), + FUNCTION: re.compile(r'[&|]\s*\\').findall + }, } ALL_RULESETS = ['728', 'style', 'all'] EXTRA_TOML_VALIDATION = { diff --git a/tests/unit/scripts/test_lint.py b/tests/unit/scripts/test_lint.py index ec4d8936b9..4029bc1c66 100644 --- a/tests/unit/scripts/test_lint.py +++ b/tests/unit/scripts/test_lint.py @@ -45,7 +45,7 @@ STYLE_CHECKS = parse_checks(['style']) UPG_CHECKS = parse_checks(['728']) -TEST_FILE = """ +TEST_FILE = ''' [visualization] [cylc] @@ -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]] @@ -155,10 +161,10 @@ host = `rose host-select thingy` %include foo.cylc -""" +''' -LINT_TEST_FILE = """ +LINT_TEST_FILE = ''' \t[scheduler] [scheduler] @@ -168,6 +174,11 @@ {% foo %} {{foo}} # {{quix}} + R1 = """ + foo & \\ + bar => \\ + baz + """ [runtime] [[this_is_ok]] @@ -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.' ) From 9b8989e1a56c865a8c7010302aab75d9f3876001 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:53:46 +0000 Subject: [PATCH 2/4] Update changes.d/6459.feat.md Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> --- changes.d/6459.feat.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes.d/6459.feat.md b/changes.d/6459.feat.md index 19fddbbd10..3263081511 100644 --- a/changes.d/6459.feat.md +++ b/changes.d/6459.feat.md @@ -1 +1 @@ -Cylc lint now checks for unecessary continuation characters in graph section. +`cylc lint` now checks for unecessary continuation characters in graph section. From 80dee8fa37a5875fb8e668aed70a26daa5f664f7 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Fri, 22 Nov 2024 08:33:22 +0000 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Hilary James Oliver --- changes.d/6459.feat.md | 2 +- cylc/flow/scripts/lint.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changes.d/6459.feat.md b/changes.d/6459.feat.md index 3263081511..6ca3c71a2a 100644 --- a/changes.d/6459.feat.md +++ b/changes.d/6459.feat.md @@ -1 +1 @@ -`cylc lint` now checks for unecessary continuation characters in graph section. +`cylc lint` now checks for unnecessary continuation characters in the graph section. diff --git a/cylc/flow/scripts/lint.py b/cylc/flow/scripts/lint.py index d26787148c..69c87ee046 100755 --- a/cylc/flow/scripts/lint.py +++ b/cylc/flow/scripts/lint.py @@ -793,7 +793,7 @@ def list_wrapper(line: str, check: Callable) -> Optional[Dict[str, str]]: }, 'U017': { 'short': ( - '`&` and `|` are line continuations without `\\`' + '`&` and `|` imply line continuation without `\\`' ), FUNCTION: re.compile(r'[&|]\s*\\').findall }, From b1f2925ea874533cfc6e991269779e4222ece0f8 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:48:03 +0000 Subject: [PATCH 4/4] Update cylc/flow/scripts/lint.py Co-authored-by: Hilary James Oliver --- cylc/flow/scripts/lint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cylc/flow/scripts/lint.py b/cylc/flow/scripts/lint.py index 69c87ee046..d7ac5c6891 100755 --- a/cylc/flow/scripts/lint.py +++ b/cylc/flow/scripts/lint.py @@ -620,7 +620,7 @@ def list_wrapper(line: str, check: Callable) -> Optional[Dict[str, str]]: }, 'S015': { 'short': ( - '`=>` is a line continuation without `\\`.' + '`=>` implies line continuation without `\\`.' ), FUNCTION: re.compile(r'=>\s*\\').findall },