Skip to content

Commit 42b28c6

Browse files
authored
Remove compat for Python lower than 3.9 (#52935)
* Remove compat for Python lower than 3.9 * Remove wheel build * Fix mypy
1 parent 103d3b2 commit 42b28c6

File tree

6 files changed

+22
-41
lines changed

6 files changed

+22
-41
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ workflows:
9292
only: /^v.*/
9393
matrix:
9494
parameters:
95-
cibw-build: ["cp38-manylinux_aarch64", "cp39-manylinux_aarch64", "cp310-manylinux_aarch64", "cp311-manylinux_aarch64"]
95+
cibw-build: ["cp39-manylinux_aarch64", "cp310-manylinux_aarch64", "cp311-manylinux_aarch64"]

pandas/compat/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from pandas.compat._constants import (
1818
IS64,
19-
PY39,
2019
PY310,
2120
PY311,
2221
PYPY,
@@ -161,7 +160,6 @@ def get_lzma_file() -> type[pandas.compat.compressors.LZMAFile]:
161160
"pa_version_under9p0",
162161
"pa_version_under11p0",
163162
"IS64",
164-
"PY39",
165163
"PY310",
166164
"PY311",
167165
"PYPY",

pandas/compat/_constants.py

-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212

1313
IS64 = sys.maxsize > 2**32
1414

15-
PY39 = sys.version_info >= (3, 9)
1615
PY310 = sys.version_info >= (3, 10)
1716
PY311 = sys.version_info >= (3, 11)
1817
PYPY = platform.python_implementation() == "PyPy"
1918

2019

2120
__all__ = [
2221
"IS64",
23-
"PY39",
2422
"PY310",
2523
"PY311",
2624
"PYPY",

pandas/conftest.py

+12-16
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
Series,
6565
Timedelta,
6666
Timestamp,
67-
compat,
6867
)
6968
import pandas._testing as tm
7069
from pandas.core import ops
@@ -81,18 +80,12 @@
8180
del pa
8281
has_pyarrow = True
8382

84-
zoneinfo = None
85-
if compat.PY39:
86-
# Import "zoneinfo" could not be resolved (reportMissingImports)
87-
import zoneinfo # type: ignore[assignment]
83+
import zoneinfo
8884

89-
# Although zoneinfo can be imported in Py39, it is effectively
90-
# "not available" without tzdata/IANA tz data.
91-
# We will set zoneinfo to not found in this case
92-
try:
93-
zoneinfo.ZoneInfo("UTC") # type: ignore[attr-defined]
94-
except zoneinfo.ZoneInfoNotFoundError: # type: ignore[attr-defined]
95-
zoneinfo = None
85+
try:
86+
zoneinfo.ZoneInfo("UTC")
87+
except zoneinfo.ZoneInfoNotFoundError:
88+
zoneinfo = None # type: ignore[assignment]
9689

9790

9891
# ----------------------------------------------------------------
@@ -1221,7 +1214,12 @@ def iris(datapath) -> DataFrame:
12211214
timezone(timedelta(hours=-1), name="foo"),
12221215
]
12231216
if zoneinfo is not None:
1224-
TIMEZONES.extend([zoneinfo.ZoneInfo("US/Pacific"), zoneinfo.ZoneInfo("UTC")])
1217+
TIMEZONES.extend(
1218+
[
1219+
zoneinfo.ZoneInfo("US/Pacific"), # type: ignore[list-item]
1220+
zoneinfo.ZoneInfo("UTC"), # type: ignore[list-item]
1221+
]
1222+
)
12251223
TIMEZONE_IDS = [repr(i) for i in TIMEZONES]
12261224

12271225

@@ -1964,9 +1962,7 @@ def using_copy_on_write() -> bool:
19641962

19651963
warsaws = ["Europe/Warsaw", "dateutil/Europe/Warsaw"]
19661964
if zoneinfo is not None:
1967-
warsaws.append(
1968-
zoneinfo.ZoneInfo("Europe/Warsaw") # pyright: ignore[reportGeneralTypeIssues]
1969-
)
1965+
warsaws.append(zoneinfo.ZoneInfo("Europe/Warsaw")) # type: ignore[arg-type]
19701966

19711967

19721968
@pytest.fixture(params=warsaws)

pandas/core/computation/expr.py

-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import numpy as np
1919

20-
from pandas.compat import PY39
2120
from pandas.errors import UndefinedVariableError
2221

2322
import pandas.core.common as com
@@ -208,9 +207,6 @@ def _filter_nodes(superclass, all_nodes=_all_nodes):
208207
_keyword_nodes = _filter_nodes(ast.keyword)
209208
_alias_nodes = _filter_nodes(ast.alias)
210209

211-
if not PY39:
212-
_slice_nodes = _filter_nodes(ast.slice)
213-
214210

215211
# nodes that we don't support directly but are needed for parsing
216212
_hacked_nodes = frozenset(["Assign", "Module", "Expr"])

pandas/tests/scalar/timestamp/test_constructors.py

+9-16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
timedelta,
66
timezone,
77
)
8+
import zoneinfo
89

910
import dateutil.tz
1011
from dateutil.tz import tzutc
@@ -13,10 +14,7 @@
1314
import pytz
1415

1516
from pandas._libs.tslibs.dtypes import NpyDatetimeUnit
16-
from pandas.compat import (
17-
PY39,
18-
PY310,
19-
)
17+
from pandas.compat import PY310
2018
from pandas.errors import OutOfBoundsDatetime
2119

2220
from pandas import (
@@ -25,9 +23,6 @@
2523
Timestamp,
2624
)
2725

28-
if PY39:
29-
import zoneinfo
30-
3126

3227
class TestTimestampConstructors:
3328
def test_construct_from_string_invalid_raises(self):
@@ -845,15 +840,13 @@ def test_timestamp_constructor_retain_fold(tz, fold):
845840
assert result == expected
846841

847842

848-
_tzs = ["dateutil/Europe/London"]
849-
if PY39:
850-
try:
851-
_tzs = [
852-
"dateutil/Europe/London",
853-
zoneinfo.ZoneInfo("Europe/London"), # type: ignore[list-item]
854-
]
855-
except zoneinfo.ZoneInfoNotFoundError:
856-
pass
843+
try:
844+
_tzs = [
845+
"dateutil/Europe/London",
846+
zoneinfo.ZoneInfo("Europe/London"),
847+
]
848+
except zoneinfo.ZoneInfoNotFoundError:
849+
_tzs = ["dateutil/Europe/London"]
857850

858851

859852
@pytest.mark.parametrize("tz", _tzs)

0 commit comments

Comments
 (0)