diff options
| author | 2020-02-25 22:54:03 +0100 | |
|---|---|---|
| committer | 2020-02-25 22:54:03 +0100 | |
| commit | 33302afd9e83cb4b5502a8b5bbe43bac450dba3f (patch) | |
| tree | 764f81d30670c3601ba8b138f59ebc91e26b5aa5 | |
| parent | Assign created task to a variable. (diff) | |
Fix `__iter__` for classes without subsections.
The previous implementation assumed the config class was a subsection, failing with a KeyError if it wasn't one.
Co-authored-by: kwzrd <[email protected]>
| -rw-r--r-- | bot/constants.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bot/constants.py b/bot/constants.py index 3776ceb84..ebd3b3d96 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -187,8 +187,9 @@ class YAMLGetter(type): 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()) + """Return generator of key: value pairs of current constants class' config values.""" + for name in cls.__annotations__: + yield name, getattr(cls, name) # Dataclasses |