Skip to content

Commit 21de051

Browse files
authored
CLN: remove Python 3.8 compat (#42374)
1 parent 74b125e commit 21de051

File tree

9 files changed

+7
-58
lines changed

9 files changed

+7
-58
lines changed

pandas/compat/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
pa_version_under4p0,
2727
)
2828

29-
PY38 = sys.version_info >= (3, 8)
3029
PY39 = sys.version_info >= (3, 9)
3130
PY310 = sys.version_info >= (3, 10)
3231
PYPY = platform.python_implementation() == "PyPy"

pandas/tests/computation/test_eval.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from pandas import (
2222
DataFrame,
2323
Series,
24-
compat,
2524
date_range,
2625
)
2726
import pandas._testing as tm
@@ -1283,10 +1282,8 @@ def test_assignment_column(self):
12831282
msg = "left hand side of an assignment must be a single name"
12841283
with pytest.raises(SyntaxError, match=msg):
12851284
df.eval("d,c = a + b")
1286-
if compat.PY38:
1287-
msg = "cannot assign to function call"
1288-
else:
1289-
msg = "can't assign to function call"
1285+
1286+
msg = "cannot assign to function call"
12901287
with pytest.raises(SyntaxError, match=msg):
12911288
df.eval('Timestamp("20131001") = a + b')
12921289

@@ -1971,9 +1968,7 @@ def test_bool_ops_fails_on_scalars(lhs, cmp, rhs, engine, parser):
19711968
"other",
19721969
[
19731970
"'x'",
1974-
pytest.param(
1975-
"...", marks=pytest.mark.xfail(not compat.PY38, reason="GH-28116")
1976-
),
1971+
"...",
19771972
],
19781973
)
19791974
def test_equals_various(other):

pandas/tests/io/json/test_pandas.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from pandas.compat import (
1313
IS64,
14-
PY38,
1514
PY310,
1615
is_platform_windows,
1716
)
@@ -1715,7 +1714,7 @@ def test_json_multiindex(self, dataframe, expected):
17151714
assert result == expected
17161715

17171716
@pytest.mark.xfail(
1718-
is_platform_windows() and PY38,
1717+
is_platform_windows(),
17191718
reason="localhost connection rejected",
17201719
strict=False,
17211720
)

pandas/tests/io/test_parquet.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313

1414
from pandas._config import get_option
1515

16-
from pandas.compat import (
17-
PY38,
18-
is_platform_windows,
19-
)
16+
from pandas.compat import is_platform_windows
2017
from pandas.compat.pyarrow import (
2118
pa_version_under1p0,
2219
pa_version_under2p0,
@@ -651,7 +648,7 @@ def test_categorical(self, pa):
651648
check_round_trip(df, pa)
652649

653650
@pytest.mark.xfail(
654-
is_platform_windows() and PY38,
651+
is_platform_windows(),
655652
reason="localhost connection rejected",
656653
strict=False,
657654
)

pandas/tests/io/test_pickle.py

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import pytest
3333

3434
from pandas.compat import (
35-
PY38,
3635
get_lzma_file,
3736
import_lzma,
3837
is_platform_little_endian,
@@ -210,7 +209,6 @@ def python_unpickler(path):
210209
pytest.param(
211210
functools.partial(pd.to_pickle, protocol=5),
212211
id="pandas_proto_5",
213-
marks=pytest.mark.skipif(not PY38, reason="protocol 5 not supported"),
214212
),
215213
],
216214
)

pandas/tests/io/xml/test_to_xml.py

-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import numpy as np
1010
import pytest
1111

12-
from pandas.compat import PY38
1312
import pandas.util._test_decorators as td
1413

1514
from pandas import DataFrame
@@ -364,10 +363,6 @@ def test_na_empty_elem_option(datapath, parser):
364363
# ATTR_COLS
365364

366365

367-
@pytest.mark.skipif(
368-
not PY38,
369-
reason=("etree alpha ordered attributes < py 3.8"),
370-
)
371366
def test_attrs_cols_nan_output(datapath, parser):
372367
expected = """\
373368
<?xml version='1.0' encoding='utf-8'?>
@@ -383,10 +378,6 @@ def test_attrs_cols_nan_output(datapath, parser):
383378
assert output == expected
384379

385380

386-
@pytest.mark.skipif(
387-
not PY38,
388-
reason=("etree alpha ordered attributes < py3.8"),
389-
)
390381
def test_attrs_cols_prefix(datapath, parser):
391382
expected = """\
392383
<?xml version='1.0' encoding='utf-8'?>
@@ -541,10 +532,6 @@ def test_hierarchical_columns(datapath, parser):
541532
assert output == expected
542533

543534

544-
@pytest.mark.skipif(
545-
not PY38,
546-
reason=("etree alpha ordered attributes < py3.8"),
547-
)
548535
def test_hierarchical_attrs_columns(datapath, parser):
549536
expected = """\
550537
<?xml version='1.0' encoding='utf-8'?>
@@ -614,10 +601,6 @@ def test_multi_index(datapath, parser):
614601
assert output == expected
615602

616603

617-
@pytest.mark.skipif(
618-
not PY38,
619-
reason=("etree alpha ordered attributes < py3.8"),
620-
)
621604
def test_multi_index_attrs_cols(datapath, parser):
622605
expected = """\
623606
<?xml version='1.0' encoding='utf-8'?>

pandas/tests/io/xml/test_xml.py

-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import numpy as np
1111
import pytest
1212

13-
from pandas.compat import PY38
1413
import pandas.util._test_decorators as td
1514

1615
from pandas import DataFrame
@@ -255,10 +254,6 @@ def test_parser_consistency_file(datapath):
255254
@tm.network
256255
@pytest.mark.slow
257256
@td.skip_if_no("lxml")
258-
@pytest.mark.skipif(
259-
not PY38,
260-
reason=("etree alpha ordered attributes < py3.8"),
261-
)
262257
def test_parser_consistency_url(datapath):
263258
url = (
264259
"https://data.cityofchicago.org/api/views/"

pandas/tests/scalar/test_nat.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pytz
1010

1111
from pandas._libs.tslibs import iNaT
12-
import pandas.compat as compat
1312

1413
from pandas.core.dtypes.common import is_datetime64_any_dtype
1514

@@ -138,13 +137,7 @@ def test_round_nat(klass, method, freq):
138137
"dst",
139138
"fromordinal",
140139
"fromtimestamp",
141-
pytest.param(
142-
"fromisocalendar",
143-
marks=pytest.mark.skipif(
144-
not compat.PY38,
145-
reason="'fromisocalendar' was added in stdlib datetime in python 3.8",
146-
),
147-
),
140+
"fromisocalendar",
148141
"isocalendar",
149142
"strftime",
150143
"strptime",
@@ -315,11 +308,6 @@ def test_overlap_public_nat_methods(klass, expected):
315308
# NaT should have *most* of the Timestamp and Timedelta methods.
316309
# In case when Timestamp, Timedelta, and NaT are overlap, the overlap
317310
# is considered to be with Timestamp and NaT, not Timedelta.
318-
319-
# "fromisocalendar" was introduced in 3.8
320-
if klass is Timestamp and not compat.PY38:
321-
expected.remove("fromisocalendar")
322-
323311
assert _get_overlap_public_nat_methods(klass) == expected
324312

325313

pandas/tests/scalar/timestamp/test_constructors.py

-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
Period,
1818
Timedelta,
1919
Timestamp,
20-
compat,
2120
)
2221
import pandas._testing as tm
2322

@@ -569,10 +568,6 @@ class SubDatetime(datetime):
569568
expected = Timestamp(2000, 1, 1)
570569
assert result == expected
571570

572-
@pytest.mark.skipif(
573-
not compat.PY38,
574-
reason="datetime.fromisocalendar was added in Python version 3.8",
575-
)
576571
def test_constructor_fromisocalendar(self):
577572
# GH 30395
578573
expected_timestamp = Timestamp("2000-01-03 00:00:00")

0 commit comments

Comments
 (0)