diff --git a/requirements.txt b/requirements.txt index 32aaeba..7c90092 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ WebOb>=1.8.0 simplegeneric -pytz netaddr>=0.7.12 # TODO: Drop this when Python 3.10 is our minimum supported version importlib_metadata>=4.4 # Apache-2.0 diff --git a/wsme/tests/test_utils.py b/wsme/tests/test_utils.py index f9464c8..66d06c8 100644 --- a/wsme/tests/test_utils.py +++ b/wsme/tests/test_utils.py @@ -1,6 +1,5 @@ import datetime import unittest -import pytz from wsme import utils @@ -27,11 +26,14 @@ class TestUtils(unittest.TestCase): good_times = [ ('12:03:54', datetime.time(12, 3, 54)), ('23:59:59.000004', datetime.time(23, 59, 59, 4)), - ('01:02:03+00:00', datetime.time(1, 2, 3, 0, pytz.UTC)), - ('01:02:03+23:59', datetime.time(1, 2, 3, 0, - pytz.FixedOffset(1439))), - ('01:02:03-23:59', datetime.time(1, 2, 3, 0, - pytz.FixedOffset(-1439))), + ('01:02:03+00:00', datetime.time( + 1, 2, 3, 0, datetime.timezone.utc)), + ('01:02:03+23:59', datetime.time( + 1, 2, 3, 0, + datetime.timezone(datetime.timedelta(minutes=1439)))), + ('01:02:03-23:59', datetime.time( + 1, 2, 3, 0, + datetime.timezone(datetime.timedelta(minutes=-1439)))), ] ill_formatted_times = [ '24-12-2004' @@ -54,13 +56,16 @@ class TestUtils(unittest.TestCase): ('2012-05-14T23:59:59.000004', datetime.datetime(2012, 5, 14, 23, 59, 59, 4)), ('1856-07-10T01:02:03+00:00', - datetime.datetime(1856, 7, 10, 1, 2, 3, 0, pytz.UTC)), + datetime.datetime(1856, 7, 10, 1, 2, 3, 0, + datetime.timezone.utc)), ('1856-07-10T01:02:03+23:59', - datetime.datetime(1856, 7, 10, 1, 2, 3, 0, - pytz.FixedOffset(1439))), + datetime.datetime( + 1856, 7, 10, 1, 2, 3, 0, + datetime.timezone(datetime.timedelta(minutes=1439)))), ('1856-07-10T01:02:03-23:59', - datetime.datetime(1856, 7, 10, 1, 2, 3, 0, - pytz.FixedOffset(-1439))), + datetime.datetime( + 1856, 7, 10, 1, 2, 3, 0, + datetime.timezone(datetime.timedelta(minutes=-1439)))), ] ill_formatted_datetimes = [ '24-32-2004', diff --git a/wsme/utils.py b/wsme/utils.py index a8e2c8b..6eb6f54 100644 --- a/wsme/utils.py +++ b/wsme/utils.py @@ -2,7 +2,6 @@ import builtins import datetime import decimal from http import client as http_client -import pytz import re try: @@ -91,14 +90,15 @@ def parse_isodatetime(value): def _parse_tzparts(parts): if 'tz_z' in parts and parts['tz_z'] == 'Z': - return pytz.UTC + return datetime.timezone.utc if 'tz_min' not in parts or not parts['tz_min']: return None tz_minute_offset = (int(parts['tz_hour']) * 60 + int(parts['tz_min'])) tz_multiplier = -1 if parts['tz_sign'] == '-' else 1 + minutes = tz_multiplier * tz_minute_offset - return pytz.FixedOffset(tz_multiplier * tz_minute_offset) + return datetime.timezone(datetime.timedelta(minutes=minutes)) def is_valid_code(code_value):