Skip to content

Commit

Permalink
Merge pull request #2555 from sopel-irc/priority-literal
Browse files Browse the repository at this point in the history
plugin: type-hint `priority` argument as `Literal[]`
  • Loading branch information
dgw authored Nov 19, 2023
2 parents 9103422 + 1196b19 commit 179ab82
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sopel/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import re
from typing import (
Callable,
Literal,
Optional,
Pattern,
Protocol,
Expand Down Expand Up @@ -1012,13 +1013,14 @@ def add_attribute(function):
return add_attribute


def priority(value: str) -> Callable:
def priority(value: Literal['low', 'medium', 'high']) -> Callable:
"""Decorate a function to be executed with higher or lower priority.
:param value: one of ``high``, ``medium``, or ``low``; defaults to ``medium``
:param value: one of ``high``, ``medium``, or ``low``
The priority allows you to control the order of callable execution, if your
plugin needs it.
The priority allows you some control over the order of callable execution,
if your plugin needs it. If a callable does not specify its ``priority``,
Sopel assumes ``medium``.
"""
def add_attribute(function):
function.priority = value
Expand Down

0 comments on commit 179ab82

Please sign in to comment.