diff --git a/cylc/flow/parsec/util.py b/cylc/flow/parsec/util.py index 785612639a3..683fed71738 100644 --- a/cylc/flow/parsec/util.py +++ b/cylc/flow/parsec/util.py @@ -20,7 +20,7 @@ """ from copy import copy -from collections import deque +from collections import deque, UserList import re import sys @@ -178,7 +178,7 @@ def printcfg(cfg, level=0, indent=0, prefix='', none_str='', key = "%s = " % key_i if cfg_i is None: value = none_str - elif isinstance(cfg_i, list): + elif isinstance(cfg_i, (list, UserList)): value = listjoin(cfg_i, none_str) elif "\n" in str(cfg_i) and key: value = '"""\n' diff --git a/cylc/flow/parsec/validate.py b/cylc/flow/parsec/validate.py index 18c19596a63..52d59e3e2c8 100644 --- a/cylc/flow/parsec/validate.py +++ b/cylc/flow/parsec/validate.py @@ -24,7 +24,7 @@ import re import shlex -from collections import deque +from collections import deque, UserList from textwrap import dedent from typing import List, Dict, Any, Optional, Tuple @@ -597,7 +597,7 @@ def strip_and_unquote_list(cls, keys, value): # allow trailing commas if values[-1] == '': values = values[0:-1] - return values + return UserList(values) @classmethod def _unquoted_list_parse(cls, keys, value): diff --git a/cylc/flow/workflow_events.py b/cylc/flow/workflow_events.py index 02d2d4166d3..7169e8190d7 100644 --- a/cylc/flow/workflow_events.py +++ b/cylc/flow/workflow_events.py @@ -15,6 +15,7 @@ # along with this program. If not, see . """Workflow event handler.""" +from collections import UserList from enum import Enum import os from shlex import quote @@ -235,7 +236,7 @@ def get_events_conf( glbl_cfg().get(['scheduler', 'mail']) ): value = getter.get(key) - if value is not None: + if value is not None and value != [] or type(value) == UserList: return value return default diff --git a/tests/unit/test_workflow_events.py b/tests/unit/test_workflow_events.py index cea2c3f2b41..fa9b2d9f248 100644 --- a/tests/unit/test_workflow_events.py +++ b/tests/unit/test_workflow_events.py @@ -19,6 +19,7 @@ import pytest +from collections import UserList from types import SimpleNamespace from cylc.flow.workflow_events import ( @@ -32,11 +33,11 @@ 'key, workflow_cfg, glbl_cfg, expected', [ ('handlers', True, True, ['stall']), - ('handlers', False, True, []), - ('handlers', False, False, []), + ('handlers', False, True, None), + ('handlers', False, False, None), ('mail events', True, True, []), ('mail events', False, True, ['abort']), - ('mail events', False, False, []), + ('mail events', False, False, None), ('from', True, True, 'docklands@railway'), ('from', False, True, 'highway@mixture'), ('from', False, False, None), @@ -65,7 +66,7 @@ def test_get_events_handler( config = SimpleNamespace() config.cfg = { 'scheduler': { - 'events': {'handlers': ['stall'], 'mail events': []}, + 'events': {'handlers': ['stall'], 'mail events': UserList()}, 'mail': {'from': 'docklands@railway'}, } if workflow_cfg else {'events': {}} }