Skip to content

CLN: Dead version checking code post minimum version bump #27063

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

Merged
merged 9 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ Other API Changes
- Most Pandas classes had a ``__bytes__`` method, which was used for getting a python2-style bytestring representation of the object. This method has been removed as a part of dropping Python2 (:issue:`26447`)
- The ``.str``-accessor has been disabled for 1-level :class:`MultiIndex`, use :meth:`MultiIndex.to_flat_index` if necessary (:issue:`23679`)
- Removed support of gtk package for clipboards (:issue:`26563`)
- Using an unsupported version of Beautiful Soup 4 will now raise an ``ImportError`` instead of a ``ValueError`` (:issue:`27063`)

.. _whatsnew_0250.deprecations:

Expand Down
7 changes: 2 additions & 5 deletions pandas/io/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

from collections import abc
from distutils.version import LooseVersion
import numbers
import os
import re
Expand Down Expand Up @@ -830,10 +829,8 @@ def _parser_dispatch(flavor):
if not _HAS_BS4:
raise ImportError(
"BeautifulSoup4 (bs4) not found, please install it")
import bs4
if LooseVersion(bs4.__version__) <= LooseVersion('4.2.0'):
raise ValueError("A minimum version of BeautifulSoup 4.2.1 "
"is required")
# Although we call this above, we want to raise here right before use.
bs4 = import_optional_dependency('bs4') # noqa:F841

else:
if not _HAS_LXML:
Expand Down
5 changes: 0 additions & 5 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import copy
from datetime import date, datetime
from distutils.version import LooseVersion
import itertools
import os
import re
Expand Down Expand Up @@ -227,10 +226,6 @@ def _tables():
import tables
_table_mod = tables

# version requirements
if LooseVersion(tables.__version__) < LooseVersion('3.0.0'):
raise ImportError("PyTables version >= 3.0.0 is required")

# set the file open policy
# return the file open policy; this changes as of pytables 3.1
# depending on the HDF5 version
Expand Down
13 changes: 4 additions & 9 deletions pandas/tests/indexes/datetimes/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Tests for DatetimeIndex timezone-related methods
"""
from datetime import date, datetime, time, timedelta, tzinfo
from distutils.version import LooseVersion

import dateutil
from dateutil.tz import gettz, tzlocal
Expand Down Expand Up @@ -554,14 +553,10 @@ def test_dti_construction_ambiguous_endpoint(self, tz):
assert times[0] == Timestamp('2013-10-26 23:00', tz=tz, freq="H")

if str(tz).startswith('dateutil'):
if LooseVersion(dateutil.__version__) < LooseVersion('2.6.0'):
# see GH#14621
assert times[-1] == Timestamp('2013-10-27 01:00:00+0000',
tz=tz, freq="H")
elif LooseVersion(dateutil.__version__) > LooseVersion('2.6.0'):
# fixed ambiguous behavior
assert times[-1] == Timestamp('2013-10-27 01:00:00+0100',
tz=tz, freq="H")
# fixed ambiguous behavior
# see GH#14621
assert times[-1] == Timestamp('2013-10-27 01:00:00+0100',
tz=tz, freq="H")
else:
assert times[-1] == Timestamp('2013-10-27 01:00:00+0000',
tz=tz, freq="H")
Expand Down
9 changes: 0 additions & 9 deletions pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import calendar
from datetime import datetime, time
from distutils.version import LooseVersion
import locale

import dateutil
from dateutil.parser import parse
from dateutil.tz.tz import tzoffset
import numpy as np
Expand Down Expand Up @@ -1739,8 +1737,6 @@ def test_parsers_dayfirst_yearfirst(self, cache):
# 2.5.2 20/12/21 [dayfirst=1, yearfirst=0] -> 2021-12-20 00:00:00
# 2.5.3 20/12/21 [dayfirst=1, yearfirst=0] -> 2021-12-20 00:00:00

is_lt_253 = LooseVersion(dateutil.__version__) < LooseVersion('2.5.3')

# str : dayfirst, yearfirst, expected
cases = {'10-11-12': [(False, False,
datetime(2012, 10, 11)),
Expand All @@ -1762,11 +1758,6 @@ def test_parsers_dayfirst_yearfirst(self, cache):
for date_str, values in cases.items():
for dayfirst, yearfirst, expected in values:

# odd comparisons across version
# let's just skip
if dayfirst and yearfirst and is_lt_253:
continue

# compare with dateutil result
dateutil_result = parse(date_str, dayfirst=dayfirst,
yearfirst=yearfirst)
Expand Down
7 changes: 0 additions & 7 deletions pandas/tests/io/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from distutils.version import LooseVersion
import os

import pytest
Expand Down Expand Up @@ -43,12 +42,6 @@ def s3_resource(tips_file, jsonl_file):
"""
pytest.importorskip('s3fs')
boto3 = pytest.importorskip('boto3')
botocore = pytest.importorskip('botocore')

if LooseVersion(botocore.__version__) < LooseVersion("1.11.0"):
# botocore leaks an uncatchable ResourceWarning before 1.11.0;
# see GH 23731 and https://github.com/boto/botocore/issues/1464
pytest.skip("botocore is leaking resources before 1.11.0")

with tm.ensure_safe_environment_variables():
# temporary workaround as moto fails for botocore >= 1.11 otherwise,
Expand Down
13 changes: 2 additions & 11 deletions pandas/tests/io/excel/test_style.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from distutils.version import LooseVersion

import numpy as np
import pytest

Expand Down Expand Up @@ -107,15 +105,8 @@ def custom_converter(css):
assert cell1.font.color.rgb != cell2.font.color.rgb
assert cell2.font.color.rgb == alpha + '0000FF'
elif ref == 'D4':
# This fails with engine=xlsxwriter due to
# https://bitbucket.org/openpyxl/openpyxl/issues/800
if engine == 'xlsxwriter' \
and (LooseVersion(openpyxl.__version__) <
LooseVersion('2.4.6')):
pass
else:
assert cell1.font.underline != cell2.font.underline
assert cell2.font.underline == 'single'
assert cell1.font.underline != cell2.font.underline
assert cell2.font.underline == 'single'
elif ref == 'B5':
assert not cell1.border.left.style
assert (cell2.border.top.style ==
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/io/pytables/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
'release beyong 3.4.4 to support numpy 1.16x'))


_default_compressor = ('blosc' if LooseVersion(tables.__version__) >=
LooseVersion('2.2') else 'zlib')
_default_compressor = 'blosc'


ignore_natural_naming_warning = pytest.mark.filterwarnings(
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def assert_framelist_equal(list1, list2, *args, **kwargs):
def test_bs4_version_fails(monkeypatch, datapath):
import bs4
monkeypatch.setattr(bs4, '__version__', '4.2')
with pytest.raises(ValueError, match="minimum version"):
with pytest.raises(ImportError, match="Pandas requires version"):
read_html(datapath("io", "data", "spam.html"), flavor='bs4')


Expand Down
13 changes: 4 additions & 9 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
""" test parquet compat """
import datetime
from distutils.version import LooseVersion
import os
from warnings import catch_warnings

Expand Down Expand Up @@ -454,10 +453,8 @@ class TestParquetFastParquet(Base):
def test_basic(self, fp, df_full):
df = df_full

# additional supported types for fastparquet
if LooseVersion(fastparquet.__version__) >= LooseVersion('0.1.4'):
df['datetime_tz'] = pd.date_range('20130101', periods=3,
tz='US/Eastern')
df['datetime_tz'] = pd.date_range('20130101', periods=3,
tz='US/Eastern')
df['timedelta'] = pd.timedelta_range('1 day', periods=3)
check_round_trip(df, fp)

Expand Down Expand Up @@ -485,8 +482,6 @@ def test_unsupported(self, fp):
self.check_error_on_write(df, fp, ValueError)

def test_categorical(self, fp):
if LooseVersion(fastparquet.__version__) < LooseVersion("0.1.3"):
pytest.skip("CategoricalDtype not supported for older fp")
df = pd.DataFrame({'a': pd.Categorical(list('abc'))})
check_round_trip(df, fp)

Expand All @@ -512,7 +507,7 @@ def test_partition_cols_supported(self, fp, df_full):
df.to_parquet(path, engine="fastparquet",
partition_cols=partition_cols, compression=None)
assert os.path.exists(path)
import fastparquet
import fastparquet # noqa: F811
actual_partition_cols = fastparquet.ParquetFile(path, False).cats
assert len(actual_partition_cols) == 2

Expand All @@ -524,7 +519,7 @@ def test_partition_on_supported(self, fp, df_full):
df.to_parquet(path, engine="fastparquet", compression=None,
partition_on=partition_cols)
assert os.path.exists(path)
import fastparquet
import fastparquet # noqa: F811
actual_partition_cols = fastparquet.ParquetFile(path, False).cats
assert len(actual_partition_cols) == 2

Expand Down
11 changes: 2 additions & 9 deletions pandas/tests/scalar/timestamp/test_rendering.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from distutils.version import LooseVersion
import pprint

import dateutil
import pytest
import pytz # noqa # a test below uses pytz but only inside a `eval` call

Expand All @@ -10,13 +8,8 @@

class TestTimestampRendering:

# dateutil zone change (only matters for repr)
if LooseVersion(dateutil.__version__) >= LooseVersion('2.6.0'):
timezones = ['UTC', 'Asia/Tokyo', 'US/Eastern',
'dateutil/US/Pacific']
else:
timezones = ['UTC', 'Asia/Tokyo', 'US/Eastern',
'dateutil/America/Los_Angeles']
timezones = ['UTC', 'Asia/Tokyo', 'US/Eastern',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prob should use our fixture for these (future PR)

'dateutil/US/Pacific']

@pytest.mark.parametrize('tz', timezones)
@pytest.mark.parametrize('freq', ['D', 'M', 'S', 'N'])
Expand Down
28 changes: 9 additions & 19 deletions pandas/tests/scalar/timestamp/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Tests for Timestamp timezone-related methods
"""
from datetime import date, datetime, timedelta
from distutils.version import LooseVersion

import dateutil
from dateutil.tz import gettz, tzoffset
Expand Down Expand Up @@ -145,31 +144,22 @@ def test_tz_localize_ambiguous_compat(self):
assert result_pytz.value == result_dateutil.value
assert result_pytz.value == 1382835600000000000

if LooseVersion(dateutil.__version__) < LooseVersion('2.6.0'):
# dateutil 2.6 buggy w.r.t. ambiguous=0
# see gh-14621
# see https://github.com/dateutil/dateutil/issues/321
assert (result_pytz.to_pydatetime().tzname() ==
result_dateutil.to_pydatetime().tzname())
assert str(result_pytz) == str(result_dateutil)
elif LooseVersion(dateutil.__version__) > LooseVersion('2.6.0'):
# fixed ambiguous behavior
assert result_pytz.to_pydatetime().tzname() == 'GMT'
assert result_dateutil.to_pydatetime().tzname() == 'BST'
assert str(result_pytz) != str(result_dateutil)
# fixed ambiguous behavior
# see gh-14621
assert result_pytz.to_pydatetime().tzname() == 'GMT'
assert result_dateutil.to_pydatetime().tzname() == 'BST'
assert str(result_pytz) != str(result_dateutil)

# 1 hour difference
result_pytz = naive.tz_localize(pytz_zone, ambiguous=1)
result_dateutil = naive.tz_localize(dateutil_zone, ambiguous=1)
assert result_pytz.value == result_dateutil.value
assert result_pytz.value == 1382832000000000000

# dateutil < 2.6 is buggy w.r.t. ambiguous timezones
if LooseVersion(dateutil.__version__) > LooseVersion('2.5.3'):
# see gh-14621
assert str(result_pytz) == str(result_dateutil)
assert (result_pytz.to_pydatetime().tzname() ==
result_dateutil.to_pydatetime().tzname())
# see gh-14621
assert str(result_pytz) == str(result_dateutil)
assert (result_pytz.to_pydatetime().tzname() ==
result_dateutil.to_pydatetime().tzname())

@pytest.mark.parametrize('tz', [pytz.timezone('US/Eastern'),
gettz('US/Eastern'),
Expand Down
20 changes: 0 additions & 20 deletions pandas/tests/tseries/offsets/test_offsets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import date, datetime, timedelta
from distutils.version import LooseVersion

import numpy as np
import pytest
Expand Down Expand Up @@ -2998,25 +2997,6 @@ def _make_timestamp(self, string, hrs_offset, tz):
offset_string = '-{hrs:02d}00'.format(hrs=-1 * hrs_offset)
return Timestamp(string + offset_string).tz_convert(tz)

def test_fallback_plural(self):
# test moving from daylight savings to standard time
import dateutil
for tz, utc_offsets in self.timezone_utc_offsets.items():
hrs_pre = utc_offsets['utc_offset_daylight']
hrs_post = utc_offsets['utc_offset_standard']

if LooseVersion(dateutil.__version__) < LooseVersion('2.6.0'):
# buggy ambiguous behavior in 2.6.0
# GH 14621
# https://github.com/dateutil/dateutil/issues/321
self._test_all_offsets(
n=3, tstart=self._make_timestamp(self.ts_pre_fallback,
hrs_pre, tz),
expected_utc_offset=hrs_post)
elif LooseVersion(dateutil.__version__) > LooseVersion('2.6.0'):
# fixed, but skip the test
continue

def test_springforward_plural(self):
# test moving from standard to daylight savings
for tz, utc_offsets in self.timezone_utc_offsets.items():
Expand Down