15
15
16
16
This module provides :pypi:`pytz` timezones.
17
17
18
- You can use this strategy to make
19
- :py:func:`hypothesis.strategies.datetimes` and
20
- :py:func:`hypothesis.strategies.times` produce timezone-aware values.
18
+ If you are unable to use the stdlib :mod:`zoneinfo` module, e.g. via the
19
+ :func:`hypothesis.strategies.timezones` strategy, you can use this
20
+ strategy with :py:func:`hypothesis.strategies.datetimes` and
21
+ :py:func:`hypothesis.strategies.times` to produce timezone-aware values.
22
+
23
+ .. deprecated:: :mod:`zoneinfo` was added
24
+ we intend to remove ``hypothesis.extra.pytz``, after libraries
25
+ such as Pandas and Django complete their own migrations.
21
26
"""
22
27
23
28
import datetime as dt
@@ -37,8 +42,12 @@ def timezones() -> st.SearchStrategy[dt.tzinfo]:
37
42
"""Any timezone in the Olsen database, as a pytz tzinfo object.
38
43
39
44
This strategy minimises to UTC, or the smallest possible fixed
40
- offset, and is designed for use with
41
- :py:func:`hypothesis.strategies.datetimes`.
45
+ offset, and is designed for use with :func:`hypothesis.strategies.datetimes`.
46
+
47
+ .. tip::
48
+ Prefer the :func:`hypothesis.strategies.timezones` strategy, which uses
49
+ the stdlib :mod:`zoneinfo` module and avoids `the many footguns in pytz
50
+ <https://blog.ganssle.io/articles/2018/03/pytz-fastest-footgun.html>`__.
42
51
"""
43
52
all_timezones = [pytz .timezone (tz ) for tz in pytz .all_timezones ]
44
53
# Some timezones have always had a constant offset from UTC. This makes
0 commit comments