Skip to content

builtins, plugin, plugins: use Priority enum instead of literal strings#2728

Open
Exirel wants to merge 2 commits intosopel-irc:masterfrom
Exirel:tweak-2557-enum-priority
Open

builtins, plugin, plugins: use Priority enum instead of literal strings#2728
Exirel wants to merge 2 commits intosopel-irc:masterfrom
Exirel:tweak-2557-enum-priority

Conversation

@Exirel
Copy link
Copy Markdown
Contributor

@Exirel Exirel commented Feb 22, 2026

Description

Part of #2557

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.

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

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.
@Exirel Exirel added this to the 8.1.0 milestone Feb 22, 2026
Comment thread sopel/plugins/rules.py Dismissed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants