From 8a3063be1764307d05ae0215b00f53b06ed33f6c Mon Sep 17 00:00:00 2001 From: Numerlor Date: Mon, 24 Feb 2020 01:30:50 +0100 Subject: Implement `__iter__` on constants YAMLGetter. Python tries to fall back on passing indices to `__getitem__` without iter implemented; failing on the first line. --- bot/constants.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bot/constants.py b/bot/constants.py index a4c65a1f8..3ecdb5b35 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -186,6 +186,10 @@ class YAMLGetter(type): def __getitem__(cls, name): return cls.__getattr__(name) + def __iter__(cls): + """Returns iterator of key: value pairs of current constants class.""" + return iter(_CONFIG_YAML[cls.section][cls.subsection].items()) + # Dataclasses class Bot(metaclass=YAMLGetter): -- cgit v1.2.3