File: 0004-remove-pytz-dependency.patch

package info (click to toggle)
pendulum 3.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,744 kB
  • sloc: python: 17,938; makefile: 30
file content (209 lines) | stat: -rw-r--r-- 7,947 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
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)