diff options
author | 2020-04-01 09:40:30 +0200 | |
---|---|---|
committer | 2020-04-01 09:53:05 +0200 | |
commit | a74debb82dba47ac843ac6b769d8d6d50f3e2f30 (patch) | |
tree | 892e5d32a19e572ced60924b672a04025e91b982 /bot/utils/__init__.py | |
parent | Deseasonify: yield ints representing days since cycle (diff) |
Deseasonify: implement __str__ for Month enum
This way, we can standardize the way Months are shown to both the user
and the developer. Note that if passing a Month member to an f-string,
the `!s` format code must be specified to ensure our __str__ is used.
Co-authored-by: MarkKoz <[email protected]>
Diffstat (limited to 'bot/utils/__init__.py')
-rw-r--r-- | bot/utils/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py index 69bff4de..35ef0a7b 100644 --- a/bot/utils/__init__.py +++ b/bot/utils/__init__.py @@ -3,7 +3,7 @@ import contextlib import re import string from datetime import datetime -from typing import List +from typing import Iterable, List import discord from discord.ext.commands import BadArgument, Context @@ -12,6 +12,11 @@ from bot.constants import Client, Month from bot.utils.pagination import LinePaginator +def human_months(months: Iterable[Month]) -> str: + """Build a comma separated list of `months`.""" + return ", ".join(str(m) for m in months) + + def resolve_current_month() -> Month: """ Determine current month w.r.t. `Client.month_override` env var. |