Skip to content

CLN: remove Python 3.8 compat #42374

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 3 commits into from
Jul 6, 2021
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: 0 additions & 1 deletion pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
pa_version_under4p0,
)

PY38 = sys.version_info >= (3, 8)
PY39 = sys.version_info >= (3, 9)
PY310 = sys.version_info >= (3, 10)
PYPY = platform.python_implementation() == "PyPy"
Expand Down
11 changes: 3 additions & 8 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from pandas import (
DataFrame,
Series,
compat,
date_range,
)
import pandas._testing as tm
Expand Down Expand Up @@ -1283,10 +1282,8 @@ def test_assignment_column(self):
msg = "left hand side of an assignment must be a single name"
with pytest.raises(SyntaxError, match=msg):
df.eval("d,c = a + b")
if compat.PY38:
msg = "cannot assign to function call"
else:
msg = "can't assign to function call"

msg = "cannot assign to function call"
with pytest.raises(SyntaxError, match=msg):
df.eval('Timestamp("20131001") = a + b')

Expand Down Expand Up @@ -1971,9 +1968,7 @@ def test_bool_ops_fails_on_scalars(lhs, cmp, rhs, engine, parser):
"other",
[
"'x'",
pytest.param(
"...", marks=pytest.mark.xfail(not compat.PY38, reason="GH-28116")
),
"...",
],
)
def test_equals_various(other):
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from pandas.compat import (
IS64,
PY38,
PY310,
is_platform_windows,
)
Expand Down Expand Up @@ -1715,7 +1714,7 @@ def test_json_multiindex(self, dataframe, expected):
assert result == expected

@pytest.mark.xfail(
is_platform_windows() and PY38,
is_platform_windows(),
reason="localhost connection rejected",
strict=False,
)
Expand Down
7 changes: 2 additions & 5 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

from pandas._config import get_option

from pandas.compat import (
PY38,
is_platform_windows,
)
from pandas.compat import is_platform_windows
from pandas.compat.pyarrow import (
pa_version_under1p0,
pa_version_under2p0,
Expand Down Expand Up @@ -651,7 +648,7 @@ def test_categorical(self, pa):
check_round_trip(df, pa)

@pytest.mark.xfail(
is_platform_windows() and PY38,
is_platform_windows(),
reason="localhost connection rejected",
strict=False,
)
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/io/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import pytest

from pandas.compat import (
PY38,
get_lzma_file,
import_lzma,
is_platform_little_endian,
Expand Down Expand Up @@ -210,7 +209,6 @@ def python_unpickler(path):
pytest.param(
functools.partial(pd.to_pickle, protocol=5),
id="pandas_proto_5",
marks=pytest.mark.skipif(not PY38, reason="protocol 5 not supported"),
),
],
)
Expand Down
17 changes: 0 additions & 17 deletions pandas/tests/io/xml/test_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy as np
import pytest

from pandas.compat import PY38
import pandas.util._test_decorators as td

from pandas import DataFrame
Expand Down Expand Up @@ -364,10 +363,6 @@ def test_na_empty_elem_option(datapath, parser):
# ATTR_COLS


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


@pytest.mark.skipif(
not PY38,
reason=("etree alpha ordered attributes < py3.8"),
)
def test_attrs_cols_prefix(datapath, parser):
expected = """\
<?xml version='1.0' encoding='utf-8'?>
Expand Down Expand Up @@ -541,10 +532,6 @@ def test_hierarchical_columns(datapath, parser):
assert output == expected


@pytest.mark.skipif(
not PY38,
reason=("etree alpha ordered attributes < py3.8"),
)
def test_hierarchical_attrs_columns(datapath, parser):
expected = """\
<?xml version='1.0' encoding='utf-8'?>
Expand Down Expand Up @@ -614,10 +601,6 @@ def test_multi_index(datapath, parser):
assert output == expected


@pytest.mark.skipif(
not PY38,
reason=("etree alpha ordered attributes < py3.8"),
)
def test_multi_index_attrs_cols(datapath, parser):
expected = """\
<?xml version='1.0' encoding='utf-8'?>
Expand Down
5 changes: 0 additions & 5 deletions pandas/tests/io/xml/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import numpy as np
import pytest

from pandas.compat import PY38
import pandas.util._test_decorators as td

from pandas import DataFrame
Expand Down Expand Up @@ -255,10 +254,6 @@ def test_parser_consistency_file(datapath):
@tm.network
@pytest.mark.slow
@td.skip_if_no("lxml")
@pytest.mark.skipif(
not PY38,
reason=("etree alpha ordered attributes < py3.8"),
)
def test_parser_consistency_url(datapath):
url = (
"https://data.cityofchicago.org/api/views/"
Expand Down
14 changes: 1 addition & 13 deletions pandas/tests/scalar/test_nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pytz

from pandas._libs.tslibs import iNaT
import pandas.compat as compat

from pandas.core.dtypes.common import is_datetime64_any_dtype

Expand Down Expand Up @@ -138,13 +137,7 @@ def test_round_nat(klass, method, freq):
"dst",
"fromordinal",
"fromtimestamp",
pytest.param(
"fromisocalendar",
marks=pytest.mark.skipif(
not compat.PY38,
reason="'fromisocalendar' was added in stdlib datetime in python 3.8",
),
),
"fromisocalendar",
"isocalendar",
"strftime",
"strptime",
Expand Down Expand Up @@ -315,11 +308,6 @@ def test_overlap_public_nat_methods(klass, expected):
# NaT should have *most* of the Timestamp and Timedelta methods.
# In case when Timestamp, Timedelta, and NaT are overlap, the overlap
# is considered to be with Timestamp and NaT, not Timedelta.

# "fromisocalendar" was introduced in 3.8
if klass is Timestamp and not compat.PY38:
expected.remove("fromisocalendar")

assert _get_overlap_public_nat_methods(klass) == expected


Expand Down
5 changes: 0 additions & 5 deletions pandas/tests/scalar/timestamp/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
Period,
Timedelta,
Timestamp,
compat,
)
import pandas._testing as tm

Expand Down Expand Up @@ -569,10 +568,6 @@ class SubDatetime(datetime):
expected = Timestamp(2000, 1, 1)
assert result == expected

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