-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Pytzectomy #11360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pytzectomy #11360
Changes from all commits
5129b0b
eec4a5a
d6339b5
23b41b1
75c5c48
f8e76bf
1364784
ab92163
07fdbe8
590ee8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Removed ``pytz`` as a dependency | ||
-------------------------------- | ||
|
||
Since ``dateutil`` and ``pytz`` both provide time zones, and matplotlib already depends on ``dateutil``, matplotlib will now use ``dateutil`` time zones internally and drop the redundant dependency on ``pytz``. While ``dateutil`` time zones are preferred (and currently recommended in the Python documentation), the explicit use of ``pytz`` zones is still supported. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,25 @@ | |
import tempfile | ||
from unittest.mock import Mock | ||
|
||
import dateutil | ||
import dateutil.tz | ||
import dateutil.rrule | ||
import numpy as np | ||
import pytest | ||
import pytz | ||
|
||
from matplotlib.testing.decorators import image_comparison | ||
import matplotlib.pyplot as plt | ||
from matplotlib.cbook import MatplotlibDeprecationWarning | ||
import matplotlib.dates as mdates | ||
|
||
|
||
def __has_pytz(): | ||
try: | ||
import pytz | ||
return True | ||
except ImportError: | ||
return False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, disturbing that this line isn't being hit. Something is indirectly pulling in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the problem is |
||
|
||
|
||
def test_date_numpyx(): | ||
# test that numpy dates work properly... | ||
base = datetime.datetime(2017, 1, 1) | ||
|
@@ -180,8 +188,8 @@ def test_RRuleLocator(): | |
|
||
def test_RRuleLocator_dayrange(): | ||
loc = mdates.DayLocator() | ||
x1 = datetime.datetime(year=1, month=1, day=1, tzinfo=pytz.UTC) | ||
y1 = datetime.datetime(year=1, month=1, day=16, tzinfo=pytz.UTC) | ||
x1 = datetime.datetime(year=1, month=1, day=1, tzinfo=mdates.UTC) | ||
y1 = datetime.datetime(year=1, month=1, day=16, tzinfo=mdates.UTC) | ||
loc.tick_values(x1, y1) | ||
# On success, no overflow error shall be thrown | ||
|
||
|
@@ -482,8 +490,8 @@ def test_date_inverted_limit(): | |
|
||
def _test_date2num_dst(date_range, tz_convert): | ||
# Timezones | ||
BRUSSELS = pytz.timezone('Europe/Brussels') | ||
UTC = pytz.UTC | ||
BRUSSELS = dateutil.tz.gettz('Europe/Brussels') | ||
UTC = mdates.UTC | ||
|
||
# Create a list of timezone-aware datetime objects in UTC | ||
# Interval is 0b0.0000011 days, to prevent float rounding issues | ||
|
@@ -575,10 +583,7 @@ def tz_convert(*args): | |
_test_date2num_dst(pd.date_range, tz_convert) | ||
|
||
|
||
@pytest.mark.parametrize("attach_tz, get_tz", [ | ||
(lambda dt, zi: zi.localize(dt), lambda n: pytz.timezone(n)), | ||
(lambda dt, zi: dt.replace(tzinfo=zi), lambda n: dateutil.tz.gettz(n))]) | ||
def test_rrulewrapper(attach_tz, get_tz): | ||
def _test_rrulewrapper(attach_tz, get_tz): | ||
SYD = get_tz('Australia/Sydney') | ||
|
||
dtstart = attach_tz(datetime.datetime(2017, 4, 1, 0), SYD) | ||
|
@@ -593,6 +598,25 @@ def test_rrulewrapper(attach_tz, get_tz): | |
assert act == exp | ||
|
||
|
||
def test_rrulewrapper(): | ||
def attach_tz(dt, zi): | ||
return dt.replace(tzinfo=zi) | ||
|
||
_test_rrulewrapper(attach_tz, dateutil.tz.gettz) | ||
|
||
|
||
@pytest.mark.pytz | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this mark? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All otherwise unspecified marks are used to register a test with the mark of that name. This indicates that the decorated test uses |
||
@pytest.mark.skipif(not __has_pytz(), reason="Requires pytz") | ||
def test_rrulewrapper_pytz(): | ||
# Test to make sure pytz zones are supported in rrules | ||
import pytz | ||
|
||
def attach_tz(dt, zi): | ||
return zi.localize(dt) | ||
|
||
_test_rrulewrapper(attach_tz, pytz.timezone) | ||
|
||
|
||
def test_DayLocator(): | ||
with pytest.raises(ValueError): | ||
mdates.DayLocator(interval=-1) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,5 @@ pytest-rerunfailures | |
pytest-timeout | ||
pytest-xdist | ||
python-dateutil | ||
sphinx | ||
tornado | ||
tox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double underscore seems a bit overkill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong preference here. I think I used double underscore because I intended it to be ephemeral. I think maybe I should switch it to:
We can drop the
del
line and switch to a single underscore if that's preferred style.