aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/converters.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2023-05-06 16:12:32 +0100
committerGravatar Chris Lovering <[email protected]>2023-05-09 15:41:50 +0100
commit613840ebcf303e84048d48ace37fb001c1afe687 (patch)
tree9acaf0bae0527fe8389483a419b44e06997ca060 /bot/utils/converters.py
parentMigrate to ruff (diff)
Apply fixes for ruff linting
Co-authored-by: wookie184 <[email protected]> Co-authored-by: Amrou Bellalouna <[email protected]>
Diffstat (limited to 'bot/utils/converters.py')
-rw-r--r--bot/utils/converters.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/bot/utils/converters.py b/bot/utils/converters.py
index 7227a406..6111b87d 100644
--- a/bot/utils/converters.py
+++ b/bot/utils/converters.py
@@ -1,5 +1,4 @@
-from datetime import datetime
-from typing import Union
+from datetime import UTC, datetime
import discord
from discord.ext import commands
@@ -47,7 +46,7 @@ class CoordinateConverter(commands.Converter):
return x, y
-SourceType = Union[commands.Command, commands.Cog]
+SourceType = commands.Command | commands.Cog
class SourceConverter(commands.Converter):
@@ -73,12 +72,12 @@ class DateConverter(commands.Converter):
"""Parse SOL or earth date (in format YYYY-MM-DD) into `int` or `datetime`. When invalid input, raise error."""
@staticmethod
- async def convert(ctx: commands.Context, argument: str) -> Union[int, datetime]:
+ async def convert(ctx: commands.Context, argument: str) -> int | datetime:
"""Parse date (SOL or earth) into `datetime` or `int`. When invalid value, raise error."""
if argument.isdecimal():
return int(argument)
try:
- date = datetime.strptime(argument, "%Y-%m-%d")
+ date = datetime.strptime(argument, "%Y-%m-%d").replace(tzinfo=UTC)
except ValueError:
raise commands.BadArgument(
f"Can't convert `{argument}` to `datetime` in format `YYYY-MM-DD` or `int` in SOL."