-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
irc, bot, builtins: add & use AbstractBot.make_identifier_memory()
helper
#2552
Conversation
This is a convenience method for people who just want default behavior matching what Sopel itself does internally. The common use cases for `SopelIdentifierMemory` require that its casemapping behave the same as what Sopel's using, and this simplifies getting there.
d953f68
to
46977b6
Compare
That'll teach me to skip at least |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice little ergonomics improvement for the core, builtins, and plugin developers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise, I'm OK. I think however that this would be better with at least one automated test, probably in test/test_coretasks.py
, by following the same ideas as the test_handle_issuport_casemapping
test.
I'm unclear on what you want to test for that isn't already covered by use of the new method in other already-tested locations. If it's about the memory's existing keys updating with the new casemapping behavior when About the best I can do—without rewriting a bunch of stuff and taking this PR far away from the original scope—is to check adding "the same" nick that now is "not the same" under the new casemapping rules. Even that's problematic, though: if memory = bot.make_identifier_memory()
memory['Test[a]'] = False
# the bot gets `CASEMAPPING=ascii` in here (omitted for brevity)
# but the previous casemapping is still in effect for the previously-added key:
assert memory['Test{a}'] == False
memory['tEST{a}'] = True # this overwrites the previous value; it doesn't add a new key
assert len(memory) == 2 # this fails; len(memory) is (still) 1 Plugins probably just shouldn't construct |
I pushed new stuff based on IRC discussion, not just out of the blue. I promise! |
As discussed on IRC, the TL;DR is: this method need to be covered by direct invocation in the test suite, so if we stop using it internally, it is still tested and properly covered. For everything else, the new commit with the added tests is the way to go. |
I added the specific tests of If you have another idea before merge (or after, idc), just holler @Exirel :) |
I already approved that years ago. 😎 |
We had ourselves a spirited discussion about the idea of having I think the three of us (@Exirel, @SnoopJ, and myself) landed on the idea that it's fine to ship this as-is and come back to add an optional argument in 8.1.0. At the same time, we can clean up the messy Assuming we don't change our consensus in the next few days, this will get merged and this comment should be the basis of a new issue for 8.1 regarding signatures both here and in the |
Description
Here is a shortcut way of getting a new
SopelIdentifierMemory
with theidentifier_factory
kwarg filled in for you so it automatically uses the bot's awareness of casemapping from the IRC server's ISUPPORT tokens.Manual casemapping selection is still possible by using the
SopelIdentifierMemory
constructor directly, of course, as before.Using this new method in the bot to initialize its
users
andchannels
automatically adds this to test coverage:(NB: That is an older coverage run, from before I expanded the docstring.)
Checklist
make qa
(runsmake lint
andmake test
)