From 613840ebcf303e84048d48ace37fb001c1afe687 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 6 May 2023 16:12:32 +0100 Subject: Apply fixes for ruff linting Co-authored-by: wookie184 Co-authored-by: Amrou Bellalouna --- bot/utils/converters.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'bot/utils/converters.py') 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." -- cgit v1.2.3