Skip to content

Commit

Permalink
bot: use optionxform()-ed setting names for existence check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dgw committed Oct 11, 2021
1 parent 83974bd commit efb9d3b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from ast import literal_eval
from datetime import datetime
import inspect
import itertools
import logging
import re
Expand Down Expand Up @@ -389,8 +390,13 @@ def post_setup(self):
"""
settings = self.settings
for section_name, section in settings.get_defined_sections():
defined_options = {
settings.parser.optionxform(opt)
for opt, _ in inspect.getmembers(section)
if not opt.startswith('_')
}
for option_name in settings.parser.options(section_name):
if not hasattr(section, option_name):
if option_name not in defined_options:
LOGGER.warning(
"Config option `%s.%s` is not defined by its section "
"and may not be recognized by Sopel.",
Expand Down

0 comments on commit efb9d3b

Please sign in to comment.