Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Python Dependencies
uses: HassanAbouelela/actions/setup-python@setup-python_v1.4.0
with:
python_version: '3.10'
python_version: '3.11'

# Start the database early to give it a chance to get ready before
# we start running tests.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/chrislovering/python-poetry-base:3.10-slim
FROM ghcr.io/chrislovering/python-poetry-base:3.11-slim

# Allow service to handle stops gracefully
STOPSIGNAL SIGQUIT
Expand Down
54 changes: 27 additions & 27 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pydis_site/apps/api/github_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pydis_site/apps/api/models/bot/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ def timestamp(self) -> datetime.datetime:
"""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,
)
2 changes: 1 addition & 1 deletion pydis_site/apps/api/models/bot/offensive_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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")


Expand Down
8 changes: 4 additions & 4 deletions pydis_site/apps/api/tests/test_deleted_messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime, timezone
from datetime import UTC, datetime

from django.urls import reverse

Expand All @@ -17,7 +17,7 @@ def setUpTestData(cls):

cls.data = {
'actor': None,
'creation': datetime.now(tz=timezone.utc).isoformat(),
'creation': datetime.now(tz=UTC).isoformat(),
'deletedmessage_set': [
{
'author': cls.author.id,
Expand Down Expand Up @@ -57,7 +57,7 @@ def setUpTestData(cls):

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,
Expand Down Expand Up @@ -89,7 +89,7 @@ def setUpTestData(cls):

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):
Expand Down
8 changes: 4 additions & 4 deletions pydis_site/apps/api/tests/test_github_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def encode(payload: dict, _: str, algorithm: str, *args, **kwargs) -> str:

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())


Expand All @@ -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",
}

Expand All @@ -75,7 +75,7 @@ def test_timeout_error(self):
# 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)

Expand Down Expand Up @@ -180,7 +180,7 @@ def get_response_get_artifact(request: httpx.Request, **_) -> httpx.Response:
head_sha="action_sha",
created_at=(
datetime.datetime
.now(tz=datetime.timezone.utc)
.now(tz=datetime.UTC)
.strftime(settings.GITHUB_TIMESTAMP_FORMAT)
),
status="completed",
Expand Down
40 changes: 20 additions & 20 deletions pydis_site/apps/api/tests/test_infractions.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -56,8 +56,8 @@ def setUpTestData(cls):
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(
Expand All @@ -66,15 +66,15 @@ def setUpTestData(cls):
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,
actor_id=cls.user.id,
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(
Expand All @@ -83,17 +83,17 @@ def setUpTestData(cls):
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,
actor_id=cls.user.id,
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):
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_filter_permanent_true(self):

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)
Expand All @@ -161,7 +161,7 @@ def test_filter_after(self):

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)
Expand All @@ -185,8 +185,8 @@ def test_filter_before_invalid(self):

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(),
Expand All @@ -199,8 +199,8 @@ def test_after_before_before(self):

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(),
Expand All @@ -214,7 +214,7 @@ def test_after_after_before_invalid(self):

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()},
Expand All @@ -226,7 +226,7 @@ def test_permanent_after_invalid(self):

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()},
Expand All @@ -238,7 +238,7 @@ def test_permanent_before_invalid(self):

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()},
Expand Down Expand Up @@ -370,7 +370,7 @@ def test_accepts_valid_data(self):
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'])
Expand Down Expand Up @@ -814,7 +814,7 @@ def create_infraction(self, _type: str, active: bool):
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
)

Expand Down
Loading