Skip to content

Drop Python 3.6 support #35214

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 68 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ebd254d
DEPS: drop 3.6 (#34472)
fangchenli Jul 10, 2020
b415ac9
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Jul 10, 2020
71d950d
DEPS: drop 3.6 (#34472)
fangchenli Jul 10, 2020
15cd795
DEPS: fix file name (#34472)
fangchenli Jul 10, 2020
45ff57f
DEPS: fix import (#34472)
fangchenli Jul 10, 2020
d6ccbaf
DEPS: fix job name (#34472)
fangchenli Jul 10, 2020
ef13449
DEPS: resolve min version conflicts (#34472)
fangchenli Jul 10, 2020
d46c764
DEPS: fix env name (#34472)
fangchenli Jul 10, 2020
07dea22
DEPS: remove py36 check in test, bump matplotlib (#34472)
fangchenli Jul 10, 2020
2f9299f
DEPS: fix travis 37 locale (#34472)
fangchenli Jul 10, 2020
f493979
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Jul 10, 2020
34d3e69
DEPS: remove PY37 check from tests (#34472)
fangchenli Jul 10, 2020
8ec1d0b
DEPS: remove import (#34472)
fangchenli Jul 11, 2020
11c8654
DEPS: remove PY37 in benchmark (#34472)
fangchenli Jul 11, 2020
3522442
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Jul 11, 2020
dd42178
try to fix timeout
fangchenli Jul 11, 2020
e3c34bd
pytable version
fangchenli Jul 11, 2020
9e676dd
update minimum version
fangchenli Jul 11, 2020
2acad80
remove xfail for test apply
fangchenli Jul 11, 2020
5d6b5df
remove import
fangchenli Jul 11, 2020
6408afa
try to fix timeout
fangchenli Jul 12, 2020
cd6d49e
try to fix timeout
fangchenli Jul 12, 2020
64ad8d2
try to fix timeout
fangchenli Jul 12, 2020
0841147
bump to 3.7.1 to fix timeout
fangchenli Jul 12, 2020
74b80de
resolve conflict
fangchenli Jul 16, 2020
7532c06
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Jul 22, 2020
65d8bbe
migrate ci
fangchenli Jul 22, 2020
d1a7d7f
fix env name
fangchenli Jul 22, 2020
b8e7040
remove py37-locale from azure
fangchenli Jul 23, 2020
2fb8e62
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Jul 27, 2020
f90ac2e
resolve conflicts
fangchenli Jul 27, 2020
cb811ca
update ci
fangchenli Jul 27, 2020
ef5641b
update ci
fangchenli Jul 27, 2020
7f67365
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Jul 29, 2020
5a6fa8d
sync with master
fangchenli Jul 29, 2020
6fe2c08
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Jul 29, 2020
0910c82
whatsnew and install doc
fangchenli Jul 29, 2020
e3f7fd3
whatsnew and install doc
fangchenli Jul 29, 2020
34a77fe
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 1, 2020
22d2c30
update environment.yml
fangchenli Aug 1, 2020
5405b57
update environment.yml
fangchenli Aug 1, 2020
90bedcf
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 4, 2020
2337e22
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 5, 2020
f1d831a
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 7, 2020
0a10c9d
uncomment azure p37 locale
fangchenli Aug 7, 2020
d42139e
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 7, 2020
a1991ec
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 7, 2020
a204500
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 7, 2020
8685719
move min pyarrow test
fangchenli Aug 7, 2020
efdb11a
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 7, 2020
968098a
bumpy numpy to 1.16.5
fangchenli Aug 7, 2020
ead2fb2
bumpy numpy to 1.16.5
fangchenli Aug 7, 2020
c3f7166
fix 32bit
fangchenli Aug 7, 2020
f1ef0d8
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 7, 2020
566e635
comment out 32bit CI
fangchenli Aug 7, 2020
106a5d7
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 8, 2020
43d2256
update numpy version in numpy/__init__.py
fangchenli Aug 8, 2020
5edb053
remove import from numpy/__init__.py
fangchenli Aug 8, 2020
f8020cf
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 8, 2020
54d2079
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 9, 2020
b71f199
Merge remote-tracking branch 'upstream/master' into drop-3.6
fangchenli Aug 10, 2020
3d56e00
filter DeprecationWarning
fangchenli Aug 10, 2020
13d4cb2
filter DeprecationWarning
fangchenli Aug 10, 2020
8ca6918
skip unreliable test for windows
fangchenli Aug 10, 2020
0fa361c
skip unreliable test for windows
fangchenli Aug 10, 2020
081f478
fix parameter order in docstring
fangchenli Aug 10, 2020
5bcbff3
skip test
fangchenli Aug 10, 2020
a69ecfe
skip test
fangchenli Aug 10, 2020
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
Prev Previous commit
Next Next commit
DEPS: remove PY37 check from tests (#34472)
  • Loading branch information
fangchenli committed Jul 10, 2020
commit 34d3e6906281b8f13116b5c42fcc40d512346eb6
207 changes: 51 additions & 156 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,181 +184,76 @@
__git_version__ = v.get("full-revisionid")
del get_versions, v


# GH 27101
# TODO: remove Panel compat in 1.0
if pandas.compat.PY37:

def __getattr__(name):
import warnings

if name == "Panel":

warnings.warn(
"The Panel class is removed from pandas. Accessing it "
"from the top-level namespace will also be removed in the next version",
FutureWarning,
stacklevel=2,
)

class Panel:
pass

return Panel

elif name == "datetime":
warnings.warn(
"The pandas.datetime class is deprecated "
"and will be removed from pandas in a future version. "
"Import from datetime module instead.",
FutureWarning,
stacklevel=2,
)

from datetime import datetime as dt

return dt

elif name == "np":

warnings.warn(
"The pandas.np module is deprecated "
"and will be removed from pandas in a future version. "
"Import numpy directly instead",
FutureWarning,
stacklevel=2,
)
import numpy as np

return np

elif name in {"SparseSeries", "SparseDataFrame"}:
warnings.warn(
f"The {name} class is removed from pandas. Accessing it from "
"the top-level namespace will also be removed in the next version",
FutureWarning,
stacklevel=2,
)

return type(name, (), {})

elif name == "SparseArray":

warnings.warn(
"The pandas.SparseArray class is deprecated "
"and will be removed from pandas in a future version. "
"Use pandas.arrays.SparseArray instead.",
FutureWarning,
stacklevel=2,
)
from pandas.core.arrays.sparse import SparseArray as _SparseArray
def __getattr__(name):
import warnings

return _SparseArray
if name == "Panel":

raise AttributeError(f"module 'pandas' has no attribute '{name}'")
warnings.warn(
"The Panel class is removed from pandas. Accessing it "
"from the top-level namespace will also be removed in the next version",
FutureWarning,
stacklevel=2,
)

class Panel:
pass

else:
return Panel

class Panel:
pass

class SparseDataFrame:
pass

class SparseSeries:
pass

class __numpy:
def __init__(self):
import numpy as np
import warnings

self.np = np
self.warnings = warnings

def __getattr__(self, item):
self.warnings.warn(
"The pandas.np module is deprecated "
"and will be removed from pandas in a future version. "
"Import numpy directly instead",
FutureWarning,
stacklevel=2,
)

try:
return getattr(self.np, item)
except AttributeError as err:
raise AttributeError(f"module numpy has no attribute {item}") from err

np = __numpy()

class __Datetime(type):
elif name == "datetime":
warnings.warn(
"The pandas.datetime class is deprecated "
"and will be removed from pandas in a future version. "
"Import from datetime module instead.",
FutureWarning,
stacklevel=2,
)

from datetime import datetime as dt

datetime = dt

def __getattr__(cls, item):
cls.emit_warning()

try:
return getattr(cls.datetime, item)
except AttributeError as err:
raise AttributeError(
f"module datetime has no attribute {item}"
) from err

def __instancecheck__(cls, other):
return isinstance(other, cls.datetime)

class __DatetimeSub(metaclass=__Datetime):
def emit_warning(dummy=0):
import warnings

warnings.warn(
"The pandas.datetime class is deprecated "
"and will be removed from pandas in a future version. "
"Import from datetime instead.",
FutureWarning,
stacklevel=3,
)

def __new__(cls, *args, **kwargs):
cls.emit_warning()
from datetime import datetime as dt

return dt(*args, **kwargs)

datetime = __DatetimeSub
return dt

class __SparseArray(type):
elif name == "np":

from pandas.core.arrays.sparse import SparseArray as sa
warnings.warn(
"The pandas.np module is deprecated "
"and will be removed from pandas in a future version. "
"Import numpy directly instead",
FutureWarning,
stacklevel=2,
)
import numpy as np

SparseArray = sa
return np

def __instancecheck__(cls, other):
return isinstance(other, cls.SparseArray)
elif name in {"SparseSeries", "SparseDataFrame"}:
warnings.warn(
f"The {name} class is removed from pandas. Accessing it from "
"the top-level namespace will also be removed in the next version",
FutureWarning,
stacklevel=2,
)

class __SparseArraySub(metaclass=__SparseArray):
def emit_warning(dummy=0):
import warnings
return type(name, (), {})

warnings.warn(
"The pandas.SparseArray class is deprecated "
"and will be removed from pandas in a future version. "
"Use pandas.arrays.SparseArray instead.",
FutureWarning,
stacklevel=3,
)
elif name == "SparseArray":

def __new__(cls, *args, **kwargs):
cls.emit_warning()
from pandas.core.arrays.sparse import SparseArray as sa
warnings.warn(
"The pandas.SparseArray class is deprecated "
"and will be removed from pandas in a future version. "
"Use pandas.arrays.SparseArray instead.",
FutureWarning,
stacklevel=2,
)
from pandas.core.arrays.sparse import SparseArray as _SparseArray

return sa(*args, **kwargs)
return _SparseArray

SparseArray = __SparseArraySub
raise AttributeError(f"module 'pandas' has no attribute '{name}'")


# module level doc-string
Expand Down
1 change: 0 additions & 1 deletion pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from pandas._typing import F

PY37 = sys.version_info >= (3, 7)
PY38 = sys.version_info >= (3, 8)
PY39 = sys.version_info >= (3, 9)
PYPY = platform.python_implementation() == "PyPy"
Expand Down
5 changes: 1 addition & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
Renamer,
ValueKeyFunc,
)
from pandas.compat import PY37
from pandas.compat._optional import import_optional_dependency
from pandas.compat.numpy import function as nv
from pandas.util._decorators import (
Expand Down Expand Up @@ -1066,9 +1065,7 @@ def itertuples(self, index=True, name="Pandas"):
# use integer indexing because of possible duplicate column names
arrays.extend(self.iloc[:, k] for k in range(len(self.columns)))

# Python versions before 3.7 support at most 255 arguments to constructors
can_return_named_tuples = PY37 or len(self.columns) + index < 255
if name is not None and can_return_named_tuples:
if name is not None:
itertuple = collections.namedtuple(name, fields, rename=True)
return map(itertuple._make, zip(*arrays))

Expand Down
22 changes: 1 addition & 21 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ class TestPDApi(Base):
# these should be deprecated in the future
deprecated_classes_in_future: List[str] = ["SparseArray"]

if not compat.PY37:
classes.extend(["Panel", "SparseSeries", "SparseDataFrame"])
# deprecated_modules.extend(["np", "datetime"])
# deprecated_classes_in_future.extend(["SparseArray"])

# external modules exposed in pandas namespace
modules: List[str] = []

Expand Down Expand Up @@ -216,14 +211,6 @@ def test_api(self):
+ self.funcs_to
+ self.private_modules
)
if not compat.PY37:
checkthese.extend(
self.deprecated_modules
+ self.deprecated_classes
+ self.deprecated_classes_in_future
+ self.deprecated_funcs_in_future
+ self.deprecated_funcs
)
self.check(pd, checkthese, self.ignored)

def test_depr(self):
Expand All @@ -236,14 +223,7 @@ def test_depr(self):
)
for depr in deprecated_list:
with tm.assert_produces_warning(FutureWarning):
deprecated = getattr(pd, depr)
if not compat.PY37:
if depr == "datetime":
deprecated.__getattr__(dir(pd.datetime.datetime)[-1])
elif depr == "SparseArray":
deprecated([])
else:
deprecated.__getattr__(dir(deprecated)[-1])
_ = getattr(pd, depr)


def test_datetime():
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/extension/arrow/test_bool.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np
import pytest

from pandas.compat import PY37

import pandas as pd
import pandas._testing as tm
from pandas.tests.extension import base
Expand Down Expand Up @@ -62,13 +60,11 @@ def test_from_dtype(self, data):
def test_from_sequence_from_cls(self, data):
super().test_from_sequence_from_cls(data)

@pytest.mark.skipif(not PY37, reason="timeout on Linux py36_locale")
@pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899")
def test_series_constructor_no_data_with_index(self, dtype, na_value):
# pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays
super().test_series_constructor_no_data_with_index(dtype, na_value)

@pytest.mark.skipif(not PY37, reason="timeout on Linux py36_locale")
@pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899")
def test_series_constructor_scalar_na_with_index(self, dtype, na_value):
# pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays
Expand Down
13 changes: 2 additions & 11 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import numpy as np
import pytest

from pandas.compat import PY37
from pandas.util._test_decorators import async_mark, skip_if_no

import pandas as pd
Expand Down Expand Up @@ -274,10 +273,7 @@ def test_itertuples(self, float_frame):
# will raise SyntaxError if trying to create namedtuple
tup3 = next(df3.itertuples())
assert isinstance(tup3, tuple)
if PY37:
assert hasattr(tup3, "_fields")
else:
assert not hasattr(tup3, "_fields")
assert hasattr(tup3, "_fields")

# GH 28282
df_254_columns = DataFrame([{f"foo_{i}": f"bar_{i}" for i in range(254)}])
Expand All @@ -288,12 +284,7 @@ def test_itertuples(self, float_frame):
df_255_columns = DataFrame([{f"foo_{i}": f"bar_{i}" for i in range(255)}])
result_255_columns = next(df_255_columns.itertuples(index=False))
assert isinstance(result_255_columns, tuple)

# Dataframes with >=255 columns will fallback to regular tuples on python < 3.7
if PY37:
assert hasattr(result_255_columns, "_fields")
else:
assert not hasattr(result_255_columns, "_fields")
assert hasattr(result_255_columns, "_fields")

def test_sequence_like_with_categorical(self):

Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pytest
import pytz

from pandas.compat import PY37, is_platform_little_endian
from pandas.compat import is_platform_little_endian
from pandas.compat.numpy import _np_version_under1p19

from pandas.core.dtypes.common import is_integer_dtype
Expand Down Expand Up @@ -1382,7 +1382,6 @@ def test_constructor_list_of_namedtuples(self):
result = DataFrame(tuples, columns=["y", "z"])
tm.assert_frame_equal(result, expected)

@pytest.mark.skipif(not PY37, reason="Requires Python >= 3.7")
def test_constructor_list_of_dataclasses(self):
# GH21910
from dataclasses import make_dataclass
Expand All @@ -1394,7 +1393,6 @@ def test_constructor_list_of_dataclasses(self):
result = DataFrame(datas)
tm.assert_frame_equal(result, expected)

@pytest.mark.skipif(not PY37, reason="Requires Python >= 3.7")
def test_constructor_list_of_dataclasses_with_varying_types(self):
# GH21910
from dataclasses import make_dataclass
Expand All @@ -1411,7 +1409,6 @@ def test_constructor_list_of_dataclasses_with_varying_types(self):
result = DataFrame(datas)
tm.assert_frame_equal(result, expected)

@pytest.mark.skipif(not PY37, reason="Requires Python >= 3.7")
def test_constructor_list_of_dataclasses_error_thrown(self):
# GH21910
from dataclasses import make_dataclass
Expand Down
Loading