From 93683cef2742b84c4c4c1cf20254e2508f2dec73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 18 Aug 2023 20:10:29 +0300 Subject: [PATCH] Use zoneinfo instead of pytz, mark pytz as banned in ruff (#98613) Refs #43439, #49643. --- pyproject.toml | 4 ++++ tests/components/unifiprotect/test_media_source.py | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4e477440cde..1587adbea74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -488,6 +488,7 @@ select = [ "SIM401", # Use get from dict with default instead of an if block "T100", # Trace found: {name} used "T20", # flake8-print + "TID251", # Banned imports "TRY004", # Prefer TypeError exception for invalid type "TRY200", # Use raise from to specify exception cause "TRY302", # Remove exception handler; error is immediately re-raised @@ -531,6 +532,9 @@ voluptuous = "vol" [tool.ruff.flake8-pytest-style] fixture-parentheses = false +[tool.ruff.flake8-tidy-imports.banned-api] +"pytz".msg = "use zoneinfo instead" + [tool.ruff.isort] force-sort-within-sections = true known-first-party = [ diff --git a/tests/components/unifiprotect/test_media_source.py b/tests/components/unifiprotect/test_media_source.py index e19985aea3f..c5690ef5e92 100644 --- a/tests/components/unifiprotect/test_media_source.py +++ b/tests/components/unifiprotect/test_media_source.py @@ -5,7 +5,6 @@ from ipaddress import IPv4Address from unittest.mock import AsyncMock, Mock, patch import pytest -import pytz from pyunifiprotect.data import ( Bootstrap, Camera, @@ -441,7 +440,7 @@ ONE_MONTH_SIMPLE = ( minute=0, second=0, microsecond=0, - tzinfo=pytz.timezone("US/Pacific"), + tzinfo=dt_util.get_time_zone("US/Pacific"), ), 1, ) @@ -454,7 +453,7 @@ TWO_MONTH_SIMPLE = ( minute=0, second=0, microsecond=0, - tzinfo=pytz.timezone("US/Pacific"), + tzinfo=dt_util.get_time_zone("US/Pacific"), ), 2, ) @@ -513,7 +512,7 @@ ONE_MONTH_TIMEZONE = ( minute=0, second=0, microsecond=0, - tzinfo=pytz.timezone("US/Pacific"), + tzinfo=dt_util.get_time_zone("US/Pacific"), ), 1, ) @@ -526,7 +525,7 @@ TWO_MONTH_TIMEZONE = ( minute=0, second=0, microsecond=0, - tzinfo=pytz.timezone("US/Pacific"), + tzinfo=dt_util.get_time_zone("US/Pacific"), ), 2, )