diff --git a/poetry.lock b/poetry.lock index 8bd3cf36..749e1d95 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. [[package]] name = "aiohttp" @@ -1416,17 +1416,6 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] -[[package]] -name = "pytz" -version = "2023.3.post1" -description = "World timezone definitions, modern and historical" -optional = false -python-versions = "*" -files = [ - {file = "pytz-2023.3.post1-py2.py3-none-any.whl", hash = "sha256:ce42d816b81b68506614c11e8937d3aa9e41007ceb50bfdcb0749b921bf646c7"}, - {file = "pytz-2023.3.post1.tar.gz", hash = "sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b"}, -] - [[package]] name = "pyupgrade" version = "3.11.0" @@ -1931,17 +1920,6 @@ files = [ {file = "tomlkit-0.12.1.tar.gz", hash = "sha256:38e1ff8edb991273ec9f6181244a6a391ac30e9f5098e7535640ea6be97a7c86"}, ] -[[package]] -name = "types-pytz" -version = "2023.3.0.1" -description = "Typing stubs for pytz" -optional = false -python-versions = "*" -files = [ - {file = "types-pytz-2023.3.0.1.tar.gz", hash = "sha256:1a7b8d4aac70981cfa24478a41eadfcd96a087c986d6f150d77e3ceb3c2bdfab"}, - {file = "types_pytz-2023.3.0.1-py3-none-any.whl", hash = "sha256:65152e872137926bb67a8fe6cc9cfd794365df86650c5d5fdc7b167b0f38892e"}, -] - [[package]] name = "typing-extensions" version = "4.7.1" @@ -2301,4 +2279,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.9.0" -content-hash = "d35e0e77b183d7b0556f7d5ddabdee0b3c4eb018c972bbde482a5823e28e0092" +content-hash = "df73244dd3ef6061831a1d69f5ae7adbcb67225711da653f3a66fcc8800bc33c" diff --git a/pyproject.toml b/pyproject.toml index d23e1c58..40dfe0a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,6 @@ backoff = ">=1.11.1" beautifulsoup4 = ">=4.11.1" certifi = ">=2023.07.22" python = "^3.9.0" -pytz = ">=2019.3" voluptuous = ">=0.11.7" websockets = ">=8.1" @@ -96,7 +95,6 @@ requests = ">=2.31.0" ruff = ">=0.0.261,<0.0.291" safety = "^2.3.1" sphinx-rtd-theme = "^1.0.0" -types-pytz = ">=2022.1,<2024.0" vulture = "^2.6" yamllint = "^1.28.0" diff --git a/simplipy/util/dt.py b/simplipy/util/dt.py index 3952efa6..b1aca5bc 100644 --- a/simplipy/util/dt.py +++ b/simplipy/util/dt.py @@ -1,9 +1,5 @@ """Define datetime utilities.""" -from datetime import datetime - -import pytz - -UTC = pytz.utc +from datetime import datetime, timezone def utc_from_timestamp(timestamp: float) -> datetime: @@ -15,4 +11,4 @@ def utc_from_timestamp(timestamp: float) -> datetime: Returns: A parsed ``datetime.datetime`` object. """ - return UTC.localize(datetime.utcfromtimestamp(timestamp)) + return datetime.fromtimestamp(timestamp, tz=timezone.utc) diff --git a/tests/system/test_v3.py b/tests/system/test_v3.py index 1a82bfd4..f0bb5ad3 100644 --- a/tests/system/test_v3.py +++ b/tests/system/test_v3.py @@ -1,13 +1,12 @@ """Define tests for v3 System objects.""" # pylint: disable=too-many-lines import logging -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from typing import Any, cast from unittest.mock import Mock import aiohttp import pytest -import pytz from aresponses import ResponsesMockServer from simplipy import API @@ -54,7 +53,9 @@ async def test_as_dict( "category": "error", "code": "2000", "timestamp": 1581823228, - "received_dt": datetime(2020, 2, 16, 3, 20, 28, tzinfo=pytz.UTC), + "received_dt": datetime( + 2020, 2, 16, 3, 20, 28, tzinfo=timezone.utc + ), "link": "http://link.to.info", "link_label": "More Info", } @@ -1680,7 +1681,7 @@ async def test_system_notifications( assert notification1.category == "error" assert notification1.code == "2000" assert notification1.received_dt == datetime( - 2020, 2, 16, 3, 20, 28, tzinfo=pytz.UTC + 2020, 2, 16, 3, 20, 28, tzinfo=timezone.utc ) assert notification1.link == "http://link.to.info" assert notification1.link_label == "More Info" diff --git a/tests/test_websocket.py b/tests/test_websocket.py index 6ab40778..5e27259c 100644 --- a/tests/test_websocket.py +++ b/tests/test_websocket.py @@ -4,13 +4,12 @@ import asyncio import logging from collections import deque -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from time import time from typing import Any from unittest.mock import AsyncMock, Mock import pytest -import pytz from aiohttp.client_exceptions import ( ClientError, ServerDisconnectedError, @@ -142,7 +141,7 @@ def test_create_event(ws_message_event: dict[str, Any]) -> None: assert event.event_type == EVENT_DISARMED_BY_MASTER_PIN assert event.info == "System Disarmed by Master PIN" assert event.system_id == 12345 - assert event.timestamp == datetime(2021, 9, 29, 23, 14, 46, tzinfo=pytz.UTC) + assert event.timestamp == datetime(2021, 9, 29, 23, 14, 46, tzinfo=timezone.utc) assert event.changed_by == "Master PIN" assert event.sensor_name == "" assert event.sensor_serial == "abcdef12"