builtins, plugin, plugins: use Priority enum instead of literal strings#2728
Open
Exirel wants to merge 2 commits intosopel-irc:masterfrom
Open
builtins, plugin, plugins: use Priority enum instead of literal strings#2728Exirel wants to merge 2 commits intosopel-irc:masterfrom
Exirel wants to merge 2 commits intosopel-irc:masterfrom
Conversation
Until now, plugins would use literal string to define rule priorities:
`low`, `medium`, and `high`. This required a bunch of constants and not
the best typing system.
This commit introduces a new way: a Priority enum that defines the three
currently supported priorities (LOW, MEDIUM, HIGH). This allows us to
handle sorting directly with the enum, and opens the possibility of
adding new priorities in the future with the least amount of changes
required.
Now, using `@plugin.priority('medium')` will raise a deprecation warning
when loading a plugin, with a helpful message to use `plugin.MEDIUM`
instead. Three shortcuts have been added to `sopel.plugin` for that
purpose.
This commit includes minor documentation improvements, and more tests,
as per usual.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of #2557
Until now, plugins would use literal string to define rule priorities:
low,medium, andhigh. This required a bunch of constants and not the best typing system.This commit introduces a new way: a Priority enum that defines the three currently supported priorities (LOW, MEDIUM, HIGH). This allows us to handle sorting directly with the enum, and opens the possibility of adding new priorities in the future with the least amount of changes required.
Now, using
@plugin.priority('medium')will raise a deprecation warning when loading a plugin, with a helpful message to useplugin.MEDIUMinstead. Three shortcuts have been added tosopel.pluginfor that purpose.This commit includes minor documentation improvements, and more tests, as per usual.
Checklist
make qa(runsmake lintandmake test)