From: Ananthu C V <weepingclown@disroot.org>
Date: Tue, 13 Aug 2024 03:01:25 +0530
Subject: remove pytz dependency

---
 pyproject.toml                    |  2 --
 tests/datetime/test_comparison.py | 18 +++++++++---------
 tests/test_helpers.py             | 13 ++++++-------
 tests/test_main.py                |  8 ++++----
 tests/time/test_sub.py            |  4 ++--
 5 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 64429ca..b2770e7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -53,7 +53,6 @@ importlib-resources = { version = ">=5.9.0", python = "<3.9" }
 
 [tool.poetry.group.test.dependencies]
 pytest = "^7.1.2"
-pytz = ">=2022.1"
 time-machine = ">=2.6.0"
 pytest-benchmark = "^4.0.0"
 
@@ -69,7 +68,6 @@ pre-commit = "^3.0.0"
 [tool.poetry.group.typing.dependencies]
 mypy = "^1.3.0"
 types-python-dateutil = "^2.8.19"
-types-pytz = ">=2022.7.1.2"
 
 [tool.poetry.group.dev.dependencies]
 babel = "^2.10.3"
diff --git a/tests/datetime/test_comparison.py b/tests/datetime/test_comparison.py
index c3cb064..fcd263a 100644
--- a/tests/datetime/test_comparison.py
+++ b/tests/datetime/test_comparison.py
@@ -2,7 +2,7 @@ from __future__ import annotations
 
 from datetime import datetime
 
-import pytz
+import zoneinfo
 
 import pendulum
 
@@ -99,7 +99,7 @@ def test_greater_than_false():
 def test_greater_than_with_timezone_true():
     d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
     d2 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
-    d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 8, 59, 59))
+    d3 = datetime(2000, 1, 1, 8, 59, 59, tzinfo=zoneinfo.ZoneInfo("America/Vancouver"))
 
     assert d1 > d2
     assert d1 > d3
@@ -108,7 +108,7 @@ def test_greater_than_with_timezone_true():
 def test_greater_than_with_timezone_false():
     d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
     d2 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
-    d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 9, 0, 1))
+    d3 = datetime(2000, 1, 1, 9, 0, 1, tzinfo=zoneinfo.ZoneInfo("America/Vancouver"))
 
     assert not d1 > d2
     assert not d1 > d3
@@ -144,7 +144,7 @@ def test_greater_than_or_equal_false():
 def test_greater_than_or_equal_with_timezone_true():
     d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
     d2 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
-    d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 8, 59, 59))
+    d3 = datetime(2000, 1, 1, 8, 59, 59, tzinfo=zoneinfo.ZoneInfo("America/Vancouver"))
 
     assert d1 >= d2
     assert d1 >= d3
@@ -153,7 +153,7 @@ def test_greater_than_or_equal_with_timezone_true():
 def test_greater_than_or_equal_with_timezone_false():
     d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
     d2 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
-    d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 9, 0, 1))
+    d3 = datetime(2000, 1, 1, 9, 0, 1, tzinfo=zoneinfo.ZoneInfo("America/Vancouver"))
 
     assert not d1 >= d2
     assert not d1 >= d3
@@ -180,7 +180,7 @@ def test_less_than_false():
 def test_less_than_with_timezone_true():
     d1 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
     d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
-    d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))
+    d3 = datetime(2000, 1, 1, 12, 0, 0, tzinfo=zoneinfo.ZoneInfo("America/Toronto"))
 
     assert d1 < d2
     assert d1 < d3
@@ -189,7 +189,7 @@ def test_less_than_with_timezone_true():
 def test_less_than_with_timezone_false():
     d1 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
     d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
-    d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))
+    d3 = datetime(2000, 1, 1, 12, 0, 0, tzinfo=zoneinfo.ZoneInfo("America/Toronto"))
 
     assert not d1 < d2
     assert not d1 < d3
@@ -225,7 +225,7 @@ def test_less_than_or_equal_false():
 def test_less_than_or_equal_with_timezone_true():
     d1 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
     d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
-    d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))
+    d3 = datetime(2000, 1, 1, 12, 0, 0, tzinfo=zoneinfo.ZoneInfo("America/Toronto"))
 
     assert d1 <= d2
     assert d1 <= d3
@@ -234,7 +234,7 @@ def test_less_than_or_equal_with_timezone_true():
 def test_less_than_or_equal_with_timezone_false():
     d1 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
     d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
-    d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))
+    d3 = datetime(2000, 1, 1, 12, 0, 0, tzinfo=zoneinfo.ZoneInfo("America/Toronto"))
 
     assert not d1 <= d2
     assert not d1 <= d3
diff --git a/tests/test_helpers.py b/tests/test_helpers.py
index e9317b9..ec5cc53 100644
--- a/tests/test_helpers.py
+++ b/tests/test_helpers.py
@@ -3,7 +3,7 @@ from __future__ import annotations
 from datetime import datetime
 
 import pytest
-import pytz
+import zoneinfo
 
 import pendulum
 
@@ -102,18 +102,17 @@ def test_precise_diff_timezone() -> None:
     assert_diff(diff, days=1, hours=5)
     assert diff.total_days == 1
 
-    # pytz
-    paris_pytz = pytz.timezone("Europe/Paris")
-    toronto_pytz = pytz.timezone("America/Toronto")
+    paris_tz = zoneinfo.ZoneInfo("Europe/Paris")
+    toronto_tz = zoneinfo.ZoneInfo("America/Toronto")
 
-    dt1 = paris_pytz.localize(datetime(2013, 3, 31, 1, 30))
-    dt2 = paris_pytz.localize(datetime(2013, 4, 1, 1, 30))
+    dt1 = datetime(2013, 3, 31, 1, 30, tzinfo=paris_tz)
+    dt2 = datetime(2013, 4, 1, 1, 30, tzinfo=paris_tz)
 
     diff = precise_diff(dt1, dt2)
     assert_diff(diff, days=1, hours=0)
     assert diff.total_days == 1
 
-    dt2 = toronto_pytz.localize(datetime(2013, 4, 1, 1, 30))
+    dt2 = datetime(2013, 4, 1, 1, 30, tzinfo=toronto_tz)
 
     diff = precise_diff(dt1, dt2)
     assert_diff(diff, days=1, hours=5)
diff --git a/tests/test_main.py b/tests/test_main.py
index 011a6b1..c765595 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -4,7 +4,7 @@ from datetime import date
 from datetime import datetime
 from datetime import time
 
-import pytz
+import zoneinfo
 
 from dateutil import tz
 
@@ -25,8 +25,8 @@ def test_instance_with_aware_datetime() -> None:
     assert now.timezone_name == "Europe/Paris"
 
 
-def test_instance_with_aware_datetime_pytz() -> None:
-    now = pendulum.instance(datetime.now(pytz.timezone("Europe/Paris")))
+def test_instance_with_aware_datetime_zoneinfo() -> None:
+    now = pendulum.instance(datetime.now(zoneinfo.ZoneInfo("Europe/Paris")))
     assert now.timezone_name == "Europe/Paris"
 
 
@@ -57,7 +57,7 @@ def test_instance_with_aware_time() -> None:
 
 
 def test_safe_timezone_with_tzinfo_objects() -> None:
-    tz = _safe_timezone(pytz.timezone("Europe/Paris"))
+    tz = _safe_timezone(zoneinfo.ZoneInfo("Europe/Paris"))
 
     assert isinstance(tz, Timezone)
     assert tz.name == "Europe/Paris"
diff --git a/tests/time/test_sub.py b/tests/time/test_sub.py
index 1a957ad..ebcd09b 100644
--- a/tests/time/test_sub.py
+++ b/tests/time/test_sub.py
@@ -4,7 +4,7 @@ from datetime import time
 from datetime import timedelta
 
 import pytest
-import pytz
+import zoneinfo
 
 import pendulum
 
@@ -87,7 +87,7 @@ def test_subtract_time():
     t = Time(12, 34, 56)
     t1 = Time(1, 1, 1)
     t2 = time(1, 1, 1)
-    t3 = time(1, 1, 1, tzinfo=pytz.timezone("Europe/Paris"))
+    t3 = time(1, 1, 1, tzinfo=zoneinfo.ZoneInfo("Europe/Paris"))
 
     diff = t - t1
     assert isinstance(diff, pendulum.Duration)
