From 509449c1a7d4230c3a4b1e335b681fbecf0313c0 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 13 May 2023 14:31:39 +0100 Subject: Use the new datetime.UTC alias over datetime.timezone.utc --- pydis_site/apps/api/github_utils.py | 6 ++-- pydis_site/apps/api/models/bot/message.py | 2 +- .../apps/api/models/bot/offensive_message.py | 2 +- pydis_site/apps/api/tests/test_deleted_messages.py | 8 ++--- pydis_site/apps/api/tests/test_github_utils.py | 8 ++--- pydis_site/apps/api/tests/test_infractions.py | 40 +++++++++++----------- pydis_site/apps/api/tests/test_models.py | 14 ++++---- pydis_site/apps/api/tests/test_nominations.py | 6 ++-- .../apps/api/tests/test_offensive_message.py | 8 ++--- pydis_site/apps/api/tests/test_reminders.py | 14 ++++---- pydis_site/apps/api/tests/test_validators.py | 6 ++-- pydis_site/apps/api/viewsets/bot/infraction.py | 4 +-- pydis_site/apps/content/tests/test_utils.py | 2 +- pydis_site/apps/content/utils.py | 4 +-- 14 files changed, 62 insertions(+), 62 deletions(-) diff --git a/pydis_site/apps/api/github_utils.py b/pydis_site/apps/api/github_utils.py index af659195..b1a7d07d 100644 --- a/pydis_site/apps/api/github_utils.py +++ b/pydis_site/apps/api/github_utils.py @@ -82,7 +82,7 @@ def generate_token() -> str: Refer to: https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app """ - now = datetime.datetime.now(tz=datetime.timezone.utc) + now = datetime.datetime.now(tz=datetime.UTC) return jwt.encode( { "iat": math.floor((now - datetime.timedelta(seconds=60)).timestamp()), # Issued at @@ -148,9 +148,9 @@ def check_run_status(run: WorkflowRun) -> str: created_at = ( datetime.datetime .strptime(run.created_at, settings.GITHUB_TIMESTAMP_FORMAT) - .replace(tzinfo=datetime.timezone.utc) + .replace(tzinfo=datetime.UTC) ) - run_time = datetime.datetime.now(tz=datetime.timezone.utc) - created_at + run_time = datetime.datetime.now(tz=datetime.UTC) - created_at if run.status != "completed": if run_time <= MAX_RUN_TIME: diff --git a/pydis_site/apps/api/models/bot/message.py b/pydis_site/apps/api/models/bot/message.py index fb3c47fc..f90f5dd0 100644 --- a/pydis_site/apps/api/models/bot/message.py +++ b/pydis_site/apps/api/models/bot/message.py @@ -68,5 +68,5 @@ class Message(ModelReprMixin, models.Model): """Attribute that represents the message timestamp as derived from the snowflake id.""" return datetime.datetime.fromtimestamp( ((self.id >> 22) + 1420070400000) / 1000, - tz=datetime.timezone.utc, + tz=datetime.UTC, ) diff --git a/pydis_site/apps/api/models/bot/offensive_message.py b/pydis_site/apps/api/models/bot/offensive_message.py index 74dab59b..41805a16 100644 --- a/pydis_site/apps/api/models/bot/offensive_message.py +++ b/pydis_site/apps/api/models/bot/offensive_message.py @@ -9,7 +9,7 @@ from pydis_site.apps.api.models.mixins import ModelReprMixin def future_date_validator(date: datetime.date) -> None: """Raise ValidationError if the date isn't a future date.""" - if date < datetime.datetime.now(datetime.timezone.utc): + if date < datetime.datetime.now(datetime.UTC): raise ValidationError("Date must be a future date") diff --git a/pydis_site/apps/api/tests/test_deleted_messages.py b/pydis_site/apps/api/tests/test_deleted_messages.py index 62d17e58..d5501202 100644 --- a/pydis_site/apps/api/tests/test_deleted_messages.py +++ b/pydis_site/apps/api/tests/test_deleted_messages.py @@ -1,4 +1,4 @@ -from datetime import datetime, timezone +from datetime import UTC, datetime from django.urls import reverse @@ -17,7 +17,7 @@ class DeletedMessagesWithoutActorTests(AuthenticatedAPITestCase): cls.data = { 'actor': None, - 'creation': datetime.now(tz=timezone.utc).isoformat(), + 'creation': datetime.now(tz=UTC).isoformat(), 'deletedmessage_set': [ { 'author': cls.author.id, @@ -57,7 +57,7 @@ class DeletedMessagesWithActorTests(AuthenticatedAPITestCase): cls.data = { 'actor': cls.actor.id, - 'creation': datetime.now(tz=timezone.utc).isoformat(), + 'creation': datetime.now(tz=UTC).isoformat(), 'deletedmessage_set': [ { 'author': cls.author.id, @@ -89,7 +89,7 @@ class DeletedMessagesLogURLTests(AuthenticatedAPITestCase): cls.deletion_context = MessageDeletionContext.objects.create( actor=cls.actor, - creation=datetime.now(tz=timezone.utc), + creation=datetime.now(tz=UTC), ) def test_valid_log_url(self): diff --git a/pydis_site/apps/api/tests/test_github_utils.py b/pydis_site/apps/api/tests/test_github_utils.py index 34fae875..d36111c9 100644 --- a/pydis_site/apps/api/tests/test_github_utils.py +++ b/pydis_site/apps/api/tests/test_github_utils.py @@ -39,7 +39,7 @@ class GeneralUtilityTests(unittest.TestCase): delta = datetime.timedelta(minutes=10) self.assertAlmostEqual(decoded["exp"] - decoded["iat"], delta.total_seconds()) - then = datetime.datetime.now(tz=datetime.timezone.utc) + delta + then = datetime.datetime.now(tz=datetime.UTC) + delta self.assertLess(decoded["exp"], then.timestamp()) @@ -51,7 +51,7 @@ class CheckRunTests(unittest.TestCase): "head_sha": "sha", "status": "completed", "conclusion": "success", - "created_at": datetime.datetime.now(tz=datetime.timezone.utc).strftime(settings.GITHUB_TIMESTAMP_FORMAT), + "created_at": datetime.datetime.now(tz=datetime.UTC).strftime(settings.GITHUB_TIMESTAMP_FORMAT), "artifacts_url": "url", } @@ -75,7 +75,7 @@ class CheckRunTests(unittest.TestCase): # Set the creation time to well before the MAX_RUN_TIME # to guarantee the right conclusion kwargs["created_at"] = ( - datetime.datetime.now(tz=datetime.timezone.utc) + datetime.datetime.now(tz=datetime.UTC) - github_utils.MAX_RUN_TIME - datetime.timedelta(minutes=10) ).strftime(settings.GITHUB_TIMESTAMP_FORMAT) @@ -180,7 +180,7 @@ class ArtifactFetcherTests(unittest.TestCase): head_sha="action_sha", created_at=( datetime.datetime - .now(tz=datetime.timezone.utc) + .now(tz=datetime.UTC) .strftime(settings.GITHUB_TIMESTAMP_FORMAT) ), status="completed", diff --git a/pydis_site/apps/api/tests/test_infractions.py b/pydis_site/apps/api/tests/test_infractions.py index 71611ee9..b9b33ff3 100644 --- a/pydis_site/apps/api/tests/test_infractions.py +++ b/pydis_site/apps/api/tests/test_infractions.py @@ -1,5 +1,5 @@ import datetime -from datetime import datetime as dt, timedelta, timezone +from datetime import UTC, datetime as dt, timedelta from unittest.mock import patch from urllib.parse import quote @@ -56,8 +56,8 @@ class InfractionTests(AuthenticatedAPITestCase): type='ban', reason='He terk my jerb!', hidden=True, - inserted_at=dt(2020, 10, 10, 0, 0, 0, tzinfo=timezone.utc), - expires_at=dt(5018, 11, 20, 15, 52, tzinfo=timezone.utc), + inserted_at=dt(2020, 10, 10, 0, 0, 0, tzinfo=UTC), + expires_at=dt(5018, 11, 20, 15, 52, tzinfo=UTC), active=True, ) cls.ban_inactive = Infraction.objects.create( @@ -66,7 +66,7 @@ class InfractionTests(AuthenticatedAPITestCase): type='ban', reason='James is an ass, and we won\'t be working with him again.', active=False, - inserted_at=dt(2020, 10, 10, 0, 1, 0, tzinfo=timezone.utc), + inserted_at=dt(2020, 10, 10, 0, 1, 0, tzinfo=UTC), ) cls.timeout_permanent = Infraction.objects.create( user_id=cls.user.id, @@ -74,7 +74,7 @@ class InfractionTests(AuthenticatedAPITestCase): type='timeout', reason='He has a filthy mouth and I am his soap.', active=True, - inserted_at=dt(2020, 10, 10, 0, 2, 0, tzinfo=timezone.utc), + inserted_at=dt(2020, 10, 10, 0, 2, 0, tzinfo=UTC), expires_at=None, ) cls.superstar_expires_soon = Infraction.objects.create( @@ -83,8 +83,8 @@ class InfractionTests(AuthenticatedAPITestCase): type='superstar', reason='This one doesn\'t matter anymore.', active=True, - inserted_at=dt(2020, 10, 10, 0, 3, 0, tzinfo=timezone.utc), - expires_at=dt.now(timezone.utc) + datetime.timedelta(hours=5), + inserted_at=dt(2020, 10, 10, 0, 3, 0, tzinfo=UTC), + expires_at=dt.now(UTC) + datetime.timedelta(hours=5), ) cls.voiceban_expires_later = Infraction.objects.create( user_id=cls.user.id, @@ -92,8 +92,8 @@ class InfractionTests(AuthenticatedAPITestCase): type='voice_ban', reason='Jet engine mic', active=True, - inserted_at=dt(2020, 10, 10, 0, 4, 0, tzinfo=timezone.utc), - expires_at=dt.now(timezone.utc) + datetime.timedelta(days=5), + inserted_at=dt(2020, 10, 10, 0, 4, 0, tzinfo=UTC), + expires_at=dt.now(UTC) + datetime.timedelta(days=5), ) def test_list_all(self): @@ -152,7 +152,7 @@ class InfractionTests(AuthenticatedAPITestCase): def test_filter_after(self): url = reverse('api:bot:infraction-list') - target_time = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=5) + target_time = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=5) response = self.client.get(url, {'type': 'superstar', 'expires_after': target_time.isoformat()}) self.assertEqual(response.status_code, 200) @@ -161,7 +161,7 @@ class InfractionTests(AuthenticatedAPITestCase): def test_filter_before(self): url = reverse('api:bot:infraction-list') - target_time = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=5) + target_time = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=5) response = self.client.get(url, {'type': 'superstar', 'expires_before': target_time.isoformat()}) self.assertEqual(response.status_code, 200) @@ -185,8 +185,8 @@ class InfractionTests(AuthenticatedAPITestCase): def test_after_before_before(self): url = reverse('api:bot:infraction-list') - target_time = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=4) - target_time_late = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=6) + target_time = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=4) + target_time_late = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=6) response = self.client.get( url, {'expires_before': target_time_late.isoformat(), @@ -199,8 +199,8 @@ class InfractionTests(AuthenticatedAPITestCase): def test_after_after_before_invalid(self): url = reverse('api:bot:infraction-list') - target_time = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=5) - target_time_late = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=9) + target_time = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=5) + target_time_late = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=9) response = self.client.get( url, {'expires_before': target_time.isoformat(), @@ -214,7 +214,7 @@ class InfractionTests(AuthenticatedAPITestCase): def test_permanent_after_invalid(self): url = reverse('api:bot:infraction-list') - target_time = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=5) + target_time = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=5) response = self.client.get( url, {'permanent': 'true', 'expires_after': target_time.isoformat()}, @@ -226,7 +226,7 @@ class InfractionTests(AuthenticatedAPITestCase): def test_permanent_before_invalid(self): url = reverse('api:bot:infraction-list') - target_time = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=5) + target_time = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=5) response = self.client.get( url, {'permanent': 'true', 'expires_before': target_time.isoformat()}, @@ -238,7 +238,7 @@ class InfractionTests(AuthenticatedAPITestCase): def test_nonpermanent_before(self): url = reverse('api:bot:infraction-list') - target_time = datetime.datetime.now(tz=timezone.utc) + datetime.timedelta(hours=6) + target_time = datetime.datetime.now(tz=UTC) + datetime.timedelta(hours=6) response = self.client.get( url, {'permanent': 'false', 'expires_before': target_time.isoformat()}, @@ -370,7 +370,7 @@ class CreationTests(AuthenticatedAPITestCase): infraction = Infraction.objects.get(id=response.json()['id']) self.assertAlmostEqual( infraction.inserted_at, - dt.now(timezone.utc), + dt.now(UTC), delta=timedelta(seconds=2) ) self.assertEqual(infraction.expires_at.isoformat(), data['expires_at']) @@ -814,7 +814,7 @@ class SerializerTests(AuthenticatedAPITestCase): actor_id=self.user.id, type=_type, reason='A reason.', - expires_at=dt(5018, 11, 20, 15, 52, tzinfo=timezone.utc), + expires_at=dt(5018, 11, 20, 15, 52, tzinfo=UTC), active=active ) diff --git a/pydis_site/apps/api/tests/test_models.py b/pydis_site/apps/api/tests/test_models.py index 1cca133d..456ac408 100644 --- a/pydis_site/apps/api/tests/test_models.py +++ b/pydis_site/apps/api/tests/test_models.py @@ -1,4 +1,4 @@ -from datetime import datetime as dt, timezone +from datetime import UTC, datetime as dt from django.core.exceptions import ValidationError from django.test import SimpleTestCase, TestCase @@ -41,7 +41,7 @@ class NitroMessageLengthTest(TestCase): self.context = MessageDeletionContext.objects.create( id=50, actor=self.user, - creation=dt.now(timezone.utc) + creation=dt.now(UTC) ) def test_create(self): @@ -99,7 +99,7 @@ class StringDunderMethodTests(SimpleTestCase): name='shawn', discriminator=555, ), - creation=dt.now(timezone.utc) + creation=dt.now(UTC) ), embeds=[] ), @@ -118,7 +118,7 @@ class StringDunderMethodTests(SimpleTestCase): OffensiveMessage( id=602951077675139072, channel_id=291284109232308226, - delete_date=dt(3000, 1, 1, tzinfo=timezone.utc) + delete_date=dt(3000, 1, 1, tzinfo=UTC) ), OffTopicChannelName(name='bob-the-builders-playground'), Role( @@ -132,7 +132,7 @@ class StringDunderMethodTests(SimpleTestCase): name='shawn', discriminator=555, ), - creation=dt.now(tz=timezone.utc) + creation=dt.now(tz=UTC) ), User( id=5, @@ -151,7 +151,7 @@ class StringDunderMethodTests(SimpleTestCase): hidden=True, type='kick', reason='He terk my jerb!', - expires_at=dt(5018, 11, 20, 15, 52, tzinfo=timezone.utc) + expires_at=dt(5018, 11, 20, 15, 52, tzinfo=UTC) ), Reminder( author=User( @@ -165,7 +165,7 @@ class StringDunderMethodTests(SimpleTestCase): '267624335836053506/291284109232308226/463087129459949587' ), content="oh no", - expiration=dt(5018, 11, 20, 15, 52, tzinfo=timezone.utc) + expiration=dt(5018, 11, 20, 15, 52, tzinfo=UTC) ), NominationEntry( nomination_id=self.nomination.id, diff --git a/pydis_site/apps/api/tests/test_nominations.py b/pydis_site/apps/api/tests/test_nominations.py index ee6b1fbd..7fe2f0a8 100644 --- a/pydis_site/apps/api/tests/test_nominations.py +++ b/pydis_site/apps/api/tests/test_nominations.py @@ -1,4 +1,4 @@ -from datetime import datetime as dt, timedelta, timezone +from datetime import UTC, datetime as dt, timedelta from django.urls import reverse @@ -38,7 +38,7 @@ class CreationTests(AuthenticatedAPITestCase): ) self.assertAlmostEqual( nomination.inserted_at, - dt.now(timezone.utc), + dt.now(UTC), delta=timedelta(seconds=2) ) self.assertEqual(nomination.user.id, data['user']) @@ -319,7 +319,7 @@ class NominationTests(AuthenticatedAPITestCase): self.assertAlmostEqual( nomination.ended_at, - dt.now(timezone.utc), + dt.now(UTC), delta=timedelta(seconds=2) ) self.assertFalse(nomination.active) diff --git a/pydis_site/apps/api/tests/test_offensive_message.py b/pydis_site/apps/api/tests/test_offensive_message.py index 53f9cb48..f45b5a66 100644 --- a/pydis_site/apps/api/tests/test_offensive_message.py +++ b/pydis_site/apps/api/tests/test_offensive_message.py @@ -16,7 +16,7 @@ class CreationTests(AuthenticatedAPITestCase): 'delete_date': delete_at.isoformat()[:-1] } - aware_delete_at = delete_at.replace(tzinfo=datetime.timezone.utc) + aware_delete_at = delete_at.replace(tzinfo=datetime.UTC) response = self.client.post(url, data=data) self.assertEqual(response.status_code, 201) @@ -73,7 +73,7 @@ class ListTests(AuthenticatedAPITestCase): @classmethod def setUpTestData(cls): delete_at = datetime.datetime.now() + datetime.timedelta(days=1) # noqa: DTZ005 - aware_delete_at = delete_at.replace(tzinfo=datetime.timezone.utc) + aware_delete_at = delete_at.replace(tzinfo=datetime.UTC) cls.messages = [ { @@ -111,7 +111,7 @@ class ListTests(AuthenticatedAPITestCase): class DeletionTests(AuthenticatedAPITestCase): @classmethod def setUpTestData(cls): - delete_at = datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(days=1) + delete_at = datetime.datetime.now(tz=datetime.UTC) + datetime.timedelta(days=1) cls.valid_offensive_message = OffensiveMessage.objects.create( id=602951077675139072, @@ -135,7 +135,7 @@ class DeletionTests(AuthenticatedAPITestCase): class NotAllowedMethodsTests(AuthenticatedAPITestCase): @classmethod def setUpTestData(cls): - delete_at = datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(days=1) + delete_at = datetime.datetime.now(tz=datetime.UTC) + datetime.timedelta(days=1) cls.valid_offensive_message = OffensiveMessage.objects.create( id=602951077675139072, diff --git a/pydis_site/apps/api/tests/test_reminders.py b/pydis_site/apps/api/tests/test_reminders.py index 9bb5fe4d..98e93bb7 100644 --- a/pydis_site/apps/api/tests/test_reminders.py +++ b/pydis_site/apps/api/tests/test_reminders.py @@ -1,4 +1,4 @@ -from datetime import datetime, timezone +from datetime import UTC, datetime from django.forms.models import model_to_dict from django.urls import reverse @@ -59,7 +59,7 @@ class ReminderCreationTests(AuthenticatedAPITestCase): data = { 'author': self.author.id, 'content': 'Remember to...wait what was it again?', - 'expiration': datetime.now(tz=timezone.utc).isoformat(), + 'expiration': datetime.now(tz=UTC).isoformat(), 'jump_url': "https://www.google.com", 'channel_id': 123, 'mentions': [8888, 9999], @@ -91,7 +91,7 @@ class ReminderDeletionTests(AuthenticatedAPITestCase): cls.reminder = Reminder.objects.create( author=cls.author, content="Don't forget to set yourself a reminder", - expiration=datetime.now(timezone.utc), + expiration=datetime.now(UTC), jump_url="https://www.decliningmentalfaculties.com", channel_id=123 ) @@ -122,7 +122,7 @@ class ReminderListTests(AuthenticatedAPITestCase): cls.reminder_one = Reminder.objects.create( author=cls.author, content="We should take Bikini Bottom, and push it somewhere else!", - expiration=datetime.now(timezone.utc), + expiration=datetime.now(UTC), jump_url="https://www.icantseemyforehead.com", channel_id=123 ) @@ -130,7 +130,7 @@ class ReminderListTests(AuthenticatedAPITestCase): cls.reminder_two = Reminder.objects.create( author=cls.author, content="Gahhh-I love being purple!", - expiration=datetime.now(timezone.utc), + expiration=datetime.now(UTC), jump_url="https://www.goofygoobersicecreampartyboat.com", channel_id=123, active=False @@ -176,7 +176,7 @@ class ReminderRetrieveTests(AuthenticatedAPITestCase): cls.reminder = Reminder.objects.create( author=cls.author, content="Reminder content", - expiration=datetime.now(timezone.utc), + expiration=datetime.now(UTC), jump_url="http://example.com/", channel_id=123 ) @@ -204,7 +204,7 @@ class ReminderUpdateTests(AuthenticatedAPITestCase): cls.reminder = Reminder.objects.create( author=cls.author, content="Squash those do-gooders", - expiration=datetime.now(timezone.utc), + expiration=datetime.now(UTC), jump_url="https://www.decliningmentalfaculties.com", channel_id=123 ) diff --git a/pydis_site/apps/api/tests/test_validators.py b/pydis_site/apps/api/tests/test_validators.py index a7ec6e38..abff8f55 100644 --- a/pydis_site/apps/api/tests/test_validators.py +++ b/pydis_site/apps/api/tests/test_validators.py @@ -1,4 +1,4 @@ -from datetime import datetime, timezone +from datetime import UTC, datetime from django.core.exceptions import ValidationError from django.test import TestCase @@ -23,8 +23,8 @@ class BotSettingValidatorTests(TestCase): class OffensiveMessageValidatorsTests(TestCase): def test_accepts_future_date(self): - future_date_validator(datetime(3000, 1, 1, tzinfo=timezone.utc)) + future_date_validator(datetime(3000, 1, 1, tzinfo=UTC)) def test_rejects_non_future_date(self): with self.assertRaises(ValidationError): - future_date_validator(datetime(1000, 1, 1, tzinfo=timezone.utc)) + future_date_validator(datetime(1000, 1, 1, tzinfo=UTC)) diff --git a/pydis_site/apps/api/viewsets/bot/infraction.py b/pydis_site/apps/api/viewsets/bot/infraction.py index ec8b83a1..26cae3ad 100644 --- a/pydis_site/apps/api/viewsets/bot/infraction.py +++ b/pydis_site/apps/api/viewsets/bot/infraction.py @@ -190,7 +190,7 @@ class InfractionViewSet( except ValueError: raise ValidationError({'expires_after': ['failed to convert to datetime']}) additional_filters['expires_at__gte'] = expires_after_parsed.replace( - tzinfo=datetime.timezone.utc + tzinfo=datetime.UTC ) filter_expires_before = self.request.query_params.get('expires_before') @@ -200,7 +200,7 @@ class InfractionViewSet( except ValueError: raise ValidationError({'expires_before': ['failed to convert to datetime']}) additional_filters['expires_at__lte'] = expires_before_parsed.replace( - tzinfo=datetime.timezone.utc + tzinfo=datetime.UTC ) if 'expires_at__lte' in additional_filters and 'expires_at__gte' in additional_filters: diff --git a/pydis_site/apps/content/tests/test_utils.py b/pydis_site/apps/content/tests/test_utils.py index 462818b5..7f7736f9 100644 --- a/pydis_site/apps/content/tests/test_utils.py +++ b/pydis_site/apps/content/tests/test_utils.py @@ -17,7 +17,7 @@ from pydis_site.apps.content.tests.helpers import ( BASE_PATH, MockPagesTestCase, PARSED_CATEGORY_INFO, PARSED_HTML, PARSED_METADATA ) -_time = datetime.datetime(2022, 10, 10, 10, 10, 10, tzinfo=datetime.timezone.utc) +_time = datetime.datetime(2022, 10, 10, 10, 10, 10, tzinfo=datetime.UTC) _time_str = _time.strftime(settings.GITHUB_TIMESTAMP_FORMAT) TEST_COMMIT_KWARGS = { "sha": "123", diff --git a/pydis_site/apps/content/utils.py b/pydis_site/apps/content/utils.py index 347640dd..56f6283d 100644 --- a/pydis_site/apps/content/utils.py +++ b/pydis_site/apps/content/utils.py @@ -132,7 +132,7 @@ def set_tag_commit(tag: Tag) -> None: tag.last_commit = Commit( sha="68da80efc00d9932a209d5cccd8d344cec0f09ea", message="Initial Commit\n\nTHIS IS FAKE DEMO DATA", - date=datetime.datetime(2018, 2, 3, 12, 20, 26, tzinfo=datetime.timezone.utc), + date=datetime.datetime(2018, 2, 3, 12, 20, 26, tzinfo=datetime.UTC), authors=json.dumps([{"name": "Joseph", "email": "joseph@josephbanks.me"}]), ) return @@ -154,7 +154,7 @@ def set_tag_commit(tag: Tag) -> None: date = ( datetime.datetime .strptime(committer["date"], settings.GITHUB_TIMESTAMP_FORMAT) - .replace(tzinfo=datetime.timezone.utc) + .replace(tzinfo=datetime.UTC) ) if author["email"] == committer["email"]: -- cgit v1.2.3