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

config: support quoting ListAttribute values #1689

Closed
wants to merge 2 commits into from
Closed

Conversation

dgw
Copy link
Member

@dgw dgw commented Sep 8, 2019

Likely a better alternative to #1687. Suggested by @Exirel a little while ago as he was heading to bed. I felt like doing something code-y, so here we are.

Most of the time I spent on this actually went into the docstring updates, which are separated into their own commit. That will make it easier to pull them out and (with minor tweaks) apply the same fixes in a separate PR if we ultimately go with a different solution to the # problem.

Of note: I removed a reference to some feature of StaticSection.configure_setting() that never worked (having prompt be an optional argument). See #864 & ab83a1f.

dgw added 2 commits September 7, 2019 19:00
Used to make `core.channels` option safe in multi-line mode. Channel
names usually start with '#'. ConfigParser interprets any line (after
stripping whitespace) that starts with '#' as a comment and ignores it.
Thus, when Sopel was told to save its config, serializing the list of
channels broke that option and the list would be loaded as empty on the
next restart. Quoting each value fixes that.

Adding this as a feature of ListAttribute itself, rather than doing the
magic elsewhere (like where the channel list is used), made this fix a
lot cleaner. It also means that plugins needing to allow '#' in their
own ListAttribute values can simply toggle this flag instead of having
to implement their own magic.

Credits: @Exirel suggested this solution right before going to bed.
I decided to implement it while he was sleeping, as a surprise. :D
There's a lot to parse (ha!) here, but most of it is pretty obvious in
purpose. The one thing I think I should explain is why all the `parse()`
and `serialize()` instances have their own docstrings now.

It's because I was having fun! Just kidding (sort of). It's actually
because Sphinx autodoc pulls the docstring from the parent class's
method if a subclass's overriding method doesn't have a docstring of its
own. In hindsight, writing new docstrings might have been *more* work
than the alternative (setting `autodoc_inherit_docstrings = False` in
`docs/conf.py` and checking to see if anything broke), but what's done
is done at this point. We can still change the setting later.
@dgw dgw added High Priority Tweak Documentation Bugfix Generally, PRs that reference (and fix) one or more issue(s) labels Sep 8, 2019
@dgw dgw added this to the 7.0.0 milestone Sep 8, 2019
@dgw dgw requested review from Exirel and a team September 8, 2019 02:07
dgw referenced this pull request Sep 8, 2019
You can't get the docstring of an attribute, sadly.

Close #864
@dgw
Copy link
Member Author

dgw commented Oct 22, 2019

Decided to go with #1690's solution. The doc updates will become a separate PR.

@dgw dgw closed this Oct 22, 2019
@dgw dgw added the Replaced Superseded by a newer PR label Oct 22, 2019
@dgw dgw removed this from the 7.0.0 milestone Oct 22, 2019
@dgw dgw removed request for a team and Exirel October 22, 2019 23:54
@dgw dgw deleted the quoted-listattribute branch October 22, 2019 23:54
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) Documentation High Priority Replaced Superseded by a newer PR Tweak
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant