Skip to content

Commit efb9d3b

Browse files
committed
bot: use optionxform()-ed setting names for existence check
This makes the existence check case insensitive, which matches the parsing behavior of `RawConfigParser`. The `ip` plugin has a `GeoIP_db_path` setting that will erroneously warn users who set it using `sopel-plugins configure`, because the parser writes out its normalized names (in this case, `geoip_db_path`) and then the previous check using `hasattr()` wouldn't find the normalized name.
1 parent 83974bd commit efb9d3b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

sopel/bot.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from ast import literal_eval
1212
from datetime import datetime
13+
import inspect
1314
import itertools
1415
import logging
1516
import re
@@ -389,8 +390,13 @@ def post_setup(self):
389390
"""
390391
settings = self.settings
391392
for section_name, section in settings.get_defined_sections():
393+
defined_options = {
394+
settings.parser.optionxform(opt)
395+
for opt, _ in inspect.getmembers(section)
396+
if not opt.startswith('_')
397+
}
392398
for option_name in settings.parser.options(section_name):
393-
if not hasattr(section, option_name):
399+
if option_name not in defined_options:
394400
LOGGER.warning(
395401
"Config option `%s.%s` is not defined by its section "
396402
"and may not be recognized by Sopel.",

0 commit comments

Comments
 (0)