Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 266427e

Browse files
committed
Use dateutil.parser instead of datetime.
Migrate to dateutil.parser.isoparse instead of datetime.datetime.fromisoformat because the latter only supportes Z for UTC in python 3.11. See python/cpython#80010
1 parent f047272 commit 266427e

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

hubuum/api/v1/tests/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
"""Provide a base class for testing api/v1."""
22

3-
import datetime
43
from base64 import b64encode
54

5+
# We use dateutil.parser.isoparse instead of datetime.datetime.fromisoformat
6+
# because the latter only supportes Z for UTC in python 3.11.
7+
# https://github.com/python/cpython/issues/80010
8+
from dateutil.parser import isoparse
69
from django.contrib.auth import get_user_model
710
from django.contrib.auth.models import Group
811
from knox.models import AuthToken
@@ -179,7 +182,7 @@ def _assert_post_and_status(self, path, status_code, data=None, client=None):
179182
def _is_iso_date(self, value):
180183
"""Assert that a value is a valid date."""
181184
try:
182-
datetime.datetime.fromisoformat(value)
185+
isoparse(value)
183186
return True
184187
except ValueError:
185188
return False

hubuum/pagination.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66

77
class HubuumFlexiblePagination(PageNumberPagination):
8-
"""
8+
"""The default pagination class for hubuum.
9+
910
A custom pagination class that allows users to set their own pagination size
1011
with a maximum limit and a default value.
1112
"""

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ rich==13.3.3 # Used for console logging.
1010
sentry-sdk[django]==1.19.1
1111
structlog_sentry==2.0.0
1212

13+
python-dateutil==2.8.2
14+
1315
psycopg2==2.9.6
1416
pyyaml==6.0
1517
uritemplate==4.1.1

requirements-test.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ rich
1010
sentry-sdk[django]
1111
structlog_sentry
1212

13+
python-dateutil
14+
1315
psycopg2-binary
1416
pyyaml
1517
uritemplate

0 commit comments

Comments
 (0)