fix: TypeError when PLUGINS is None

When the PLUGINS config entry is None (`PLUGINS:`), the following error
was being triggered:

  File "/.../tutor/tutor/plugins.py",
  line 304, in is_enabled
      return name in config.get(CONFIG_KEY, [])
      TypeError: argument of type 'NoneType' is not iterable
This commit is contained in:
Régis Behmo 2021-03-30 06:18:02 +02:00 committed by Régis Behmo
parent 8db1495497
commit c01f4476b8
3 changed files with 7 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".
## Unreleased
- [Bugfix] Fix edge case where `PLUGINS` entry is null in config.yml.
- [Bugfix] Fix missing py2neo dependency in `images build openedx` (#411).
## v11.2.4 (2021-03-17)

View File

@ -81,6 +81,10 @@ class PluginsTests(unittest.TestCase):
self.assertEqual([], config["PLUGINS"])
self.assertNotIn("KEY", config)
def test_none_plugins(self) -> None:
config = {plugins.CONFIG_KEY: None}
self.assertFalse(plugins.is_enabled(config, "myplugin"))
def test_patches(self) -> None:
class plugin1:
patches = {"patch1": "Hello {{ ID }}"}

View File

@ -410,7 +410,8 @@ def iter_enabled(config: Dict[str, Any]) -> Iterator[BasePlugin]:
def is_enabled(config: Dict[str, Any], name: str) -> bool:
return name in config.get(CONFIG_KEY, [])
plugin_list = config.get(CONFIG_KEY) or []
return name in plugin_list
def iter_patches(config: Dict[str, str], name: str) -> Iterator[Tuple[str, str]]: