-
-
Notifications
You must be signed in to change notification settings - Fork 406
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: rework parsing of modestrings #2131
Conversation
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.
OK, I finally went through it. Some pretty significant questions wound up in those line notes. I was surprised, not least because I'm not that alert tonight and expected to miss stuff. x)
8dd8d8a
to
178e392
Compare
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.
I'm back again! Loving the added snark peppered in the docs.
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.
We must be getting close.
We are getting close. |
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.
I deem this "close enough", mostly because the best way to find any remaining edge cases (or documentation mistakes) is going to be shipping this and having people use it in production testing environments. Squash the fixups and then bug @half-duplex (who wrote some of the logic this replaces) to take a look if he's willing.
50891c0
to
3fb6cc1
Compare
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.
Nice to find some cases fixed I hadn't thought of, and see the Enterprise™ version of something I wrote ^.^
Last round of fixes is available! Hopefully, will be the actual last one. 🤷 |
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.
I'm out of enumerable nits 😛
@Exirel I think this means you can squash. 🚀 |
Co-authored-by: dgw <dgw@technobabbl.es>
Instead of creating an instance of `ModeParser` at each MODE event, the bot has a `modeparser` attribute with appropriate default values for its chanmodes, privileges, and param types. For that to work, when the bot received new ISUPPORT parameters, it updates the chanmodes and privileges of the mode parser if necessary. This required to adapt the list of default modes, as `a` and `q` are more commonly used as privilege rather than modes. Tests have been updated to manually update the modeparser. This may require new methods on the test IRC server to streamline an ISUPPORT configuration, because right now it's a bit too manual.
Several improvements of the ModeParser.parse method, which was renamed from ModeParser.parse_modestring (renamed to prevent name conflict with sopel.irc.modes.parse_modestring function). The method ModeParser.get_mode_info doesn't try to parse privileges anymore, which make it more type-safe as the letter is now str instead of Optional[str]. This makes the logic in ModeParser.parse a little different in a good way. Overall, a better type definition helped built a better interface with less potential for issues later. Functionnal tests for ModeParser.parse are kept the same, as nothing has change on this side. Thanks to mal who caught the type inconsistency in the first place!
Co-authored-by: mal <mal@sec.gd>
675bcf7
to
ee5dca2
Compare
🚀 landed. |
I'm sure CI will fail thanks to #2210, but 4 months in the PR list was enough for this patch. |
Description
Following the work on #2098 I was able to refactor that part of the modestring parsing I had in mind since a long time ago. My main goal was to extract the parsing logic, and separate it from the application of new modes & privileges to users.
So now there is a
sopel.irc.modes
module that contains only modestring parsing (with the appropriate tests), and this module is then used in thecoretasks
plugin. There is close to 0 change in behavior, but there is at least two I can remember:deepcopy
to get the existing channel modes to prevent any mutability issueschannel.modes = modes
wasn't done; this is now fixedNo tests on coretasks have been modified, although I used them locally to ensure that 1. it worked as intended, and 2. without breaking changes. And yes, at first, they didn't pass, and I had to fix what was broken in my code. So I'm pretty happy about all this. As said on IRC, this wasn't possible without the work of @half-duplex that relentlessly fixed the modeparsing before.
One last thing: I used type hint on
sopel.irc.modes
and validated it withmypy
: so far, so good. I might do more of that later. I just hope it works fine with Py3.6 because I know for a fact that type hinting changed in later versions. Further conversation need to happen around Py3.10 too, because that version might not be easy to support while supporting 3.6.Checklist
make qa
(runsmake quality
andmake test
)