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

privileges, plugin, tools.target, docs: channel privileges as IntFlag #2540

Merged
merged 3 commits into from
Nov 10, 2023

Conversation

dgw
Copy link
Member

@dgw dgw commented Nov 1, 2023

Description

Rather than have someone open an issue, I decided to Just Do It. I realized that the time to change how these constants are defined/accessed is now, as they've been moved to a new location but the new location hasn't appeared in a release yet. After we release 8.0, it would be that much more painful to change this a second time.

I'm open to bikeshedding on the class name here. If nothing else, maybe it should be plural to match sopel.formatting.colors. I'm keeping in mind the fact that we keep thinking about better access controls on bot functions, and other stuff that might also logically have constants living in sopel.privileges. AccessLevel is perhaps not the most future-proof choice for avoiding ambiguity. Other ideas included just plain Level, Channel, ChannelPrivilege, ChanPriv, and a few more I forgot.

If we do this, the type annotation changes in plugin will resolve #2538. Decorators that take this type will link to it in their function signatures' type annotations:

image

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 lint and make test)
  • I have tested the functionality of the things this change touches

Notes

Honestly, privileges.Channel made the most sense to me as far as a future collection of different kinds of privileges went. Having two different types named Channel—here, and in tools.target—sounds like a terrible idea in the long term, though. tools.target.Channel even has logic to manipulate the hypothetical privileges.Channel type. Getting into "wait, which kind of Channel is this?" sounded very not-fun.

@dgw dgw added the Tweak label Nov 1, 2023
@dgw dgw added this to the 8.0.0 milestone Nov 1, 2023
@dgw dgw requested a review from a team November 1, 2023 00:14
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.

I'd rather have the docstring kept at the module level, however this is in no way a blocker for me, as both version works for me. Also a nitpick that isn't important either.

Aside from that, I really like the idea of the ENUM!

sopel/privileges.py Outdated Show resolved Hide resolved
sopel/privileges.py Outdated Show resolved Hide resolved
sopel/privileges.py Show resolved Hide resolved
sopel/privileges.py Outdated Show resolved Hide resolved
sopel/privileges.py Outdated Show resolved Hide resolved
sopel/privileges.py Outdated Show resolved Hide resolved
I figure getting "rewrite sopel/privileges.py (97%)" is the most
justified I'll ever be in my life for adding a copyright comment. :D
The history and brief overview of how IRC privileges work is not part of
the module/class documentation. It's more appropriate to explain in the
doc page about privileges as a general concept.
Super-duper deemphasized that privileges are integer values. Removed the
actual values from code examples, to show logic only.

Condensed admonitions about nonstandard privilege levels/modes into a
single location, with cross-references.
Copy link
Contributor

@SnoopJ SnoopJ left a comment

Choose a reason for hiding this comment

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

Looks great :shipit:

@dgw dgw merged commit 51300a1 into master Nov 10, 2023
15 checks passed
@dgw dgw deleted the privileges-enum branch November 10, 2023 23:18
@dgw dgw mentioned this pull request Nov 11, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: privileges now on another page and not linked
3 participants