diff options
| author | 2020-02-24 01:30:50 +0100 | |
|---|---|---|
| committer | 2020-02-24 01:30:50 +0100 | |
| commit | 8a3063be1764307d05ae0215b00f53b06ed33f6c (patch) | |
| tree | 800b93fd1daecfe97d376ee6c61509fb67b6054a | |
| parent | Add Sentdex server to whitelist (diff) | |
Implement `__iter__` on constants YAMLGetter.
Python tries to fall back on passing indices to `__getitem__` without iter implemented; failing on the first line.
| -rw-r--r-- | bot/constants.py | 4 |
1 files changed, 4 insertions, 0 deletions
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): |