Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot: use optionxform()-ed setting names for existence check #2193

Merged
merged 1 commit into from
Oct 11, 2021

Conversation

dgw
Copy link
Member

@dgw dgw commented Oct 9, 2021

Description

This makes the "setting is defined in section" 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.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches
    • GeoIP_db_path, geoip_db_path, and i_dont_exist settings under the [ip] section all behaved as expected (respectively: silent, silent, warning).

Notes

Trivial to backport onto 7.1.x (I've already test-cherry-picked the commit locally; no conflicts), so might as well include it in the upcoming maintenance release we already plan to make.

A nicer future solution could be overriding StaticSection.__getattr__() to just always be case insensitive—but such a big change wouldn't fly in a maintenance release.

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.
@dgw dgw added Low Priority Bugfix Generally, PRs that reference (and fix) one or more issue(s) labels Oct 9, 2021
@dgw dgw added this to the 7.1.5 milestone Oct 9, 2021
@dgw dgw requested a review from a team October 9, 2021 05:20
Copy link
Contributor

@Exirel Exirel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fancy set-comprehension you got here my friend.

@dgw
Copy link
Member Author

dgw commented Oct 9, 2021

Oh yeah, I'll have to make that not-a-set-comprehension for py2 when I backport this 😑 Or maybe not, since set comprehensions should work in any 3.x and in 2.7.

@dgw dgw merged commit d6c62ce into master Oct 11, 2021
@dgw dgw deleted the casefold-config-keys branch October 11, 2021 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix Generally, PRs that reference (and fix) one or more issue(s) Low Priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants