Skip to content

Commit b598270

Browse files
committed
CI: test on 3.12
1 parent c0ca527 commit b598270

File tree

7 files changed

+479
-369
lines changed

7 files changed

+479
-369
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
os: [ubuntu-latest, windows-latest, macos-latest]
21-
python-version: ['3.9', '3.10', '3.11']
21+
python-version: ['3.9', '3.10', '3.11', '3.12']
2222

2323
steps:
2424
- uses: actions/checkout@v3

pandas-stubs/_libs/tslibs/timestamps.pyi

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ from datetime import (
66
timedelta,
77
tzinfo as _tzinfo,
88
)
9+
import sys
910
from time import struct_time
1011
from typing import (
1112
ClassVar,
@@ -99,8 +100,16 @@ class Timestamp(datetime):
99100
def tz(self) -> _tzinfo | None: ...
100101
@property
101102
def fold(self) -> int: ...
102-
@classmethod
103-
def fromtimestamp(cls, t: float, tz: _tzinfo | str | None = ...) -> Self: ...
103+
104+
if sys.version_info < (3, 12):
105+
@classmethod
106+
def fromtimestamp(cls, t: float, tz: _tzinfo | str | None = ...) -> Self: ...
107+
else:
108+
@classmethod
109+
def fromtimestamp( # pyright: ignore[reportIncompatibleMethodOverride]
110+
cls, t: float, tz: _tzinfo | str | None = ...
111+
) -> Self: ...
112+
104113
@classmethod
105114
def utcfromtimestamp(cls, ts: float) -> Self: ...
106115
@classmethod

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ types-pytz = ">= 2022.1.1"
3535
numpy = { version = ">=1.26.0", python = "<3.13" }
3636

3737
[tool.poetry.group.dev.dependencies]
38-
mypy = "1.7.1"
38+
mypy = "1.8.0"
3939
pandas = "2.1.4"
4040
pyarrow = ">=10.0.1"
4141
pytest = ">=7.1.2"
@@ -61,7 +61,6 @@ jinja2 = ">=3.1"
6161
scipy = { version = ">=1.9.1", python = "<3.13" }
6262
SQLAlchemy = ">=2.0.12"
6363
types-python-dateutil = ">=2.8.19"
64-
numexpr = "<2.8.5" # https://github.com/pandas-dev/pandas/issues/54449
6564
beautifulsoup4 = ">=4.12.2"
6665
html5lib = ">=1.1"
6766

tests/__init__.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,29 @@
77
)
88
import os
99
import platform
10+
import sys
1011
from typing import (
1112
TYPE_CHECKING,
1213
Final,
14+
TypeVar,
1315
)
1416

15-
import pandas as pd
16-
from pandas.util.version import Version
1717
import pytest
1818

19-
from pandas._typing import T
19+
if sys.version_info < (3, 12):
20+
import pandas as pd
21+
else:
22+
with pytest.warns(DeprecationWarning, match="datetime.datetime.utcfromtimestamp"):
23+
import pandas as pd
24+
from pandas.util.version import Version
2025

26+
_T = TypeVar("_T")
2127
TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING
2228
WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower()
2329
PD_LTE_21 = Version(pd.__version__) < Version("2.1.999")
2430

2531

26-
def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left") -> T:
32+
def check(actual: _T, klass: type, dtype: type | None = None, attr: str = "left") -> _T:
2733
if not isinstance(actual, klass):
2834
raise RuntimeError(f"Expected type '{klass}' but got '{type(actual)}'")
2935
if dtype is None:

tests/test_frame.py

+25-18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io
1515
import itertools
1616
from pathlib import Path
17+
import platform
1718
import string
1819
from typing import (
1920
TYPE_CHECKING,
@@ -1821,24 +1822,30 @@ def test_frame_getitem_isin() -> None:
18211822
def test_to_excel() -> None:
18221823
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
18231824

1824-
with ensure_clean() as path:
1825-
df.to_excel(path, engine="openpyxl")
1826-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1827-
with ensure_clean() as path:
1828-
df.to_excel(Path(path), engine="openpyxl")
1829-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1830-
with ensure_clean() as path:
1831-
df.to_excel(path, engine="openpyxl", startrow=1, startcol=1, header=False)
1832-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1833-
with ensure_clean() as path:
1834-
df.to_excel(path, engine="openpyxl", sheet_name="sheet", index=False)
1835-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1836-
with ensure_clean() as path:
1837-
df.to_excel(path, engine="openpyxl", header=["x", "y"])
1838-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1839-
with ensure_clean() as path:
1840-
df.to_excel(path, engine="openpyxl", columns=["col1"])
1841-
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1825+
with pytest_warns_bounded(
1826+
DeprecationWarning,
1827+
match="datetime.datetime.utcnow",
1828+
lower="3.11.99",
1829+
version_str=platform.python_version(),
1830+
):
1831+
with ensure_clean() as path:
1832+
df.to_excel(path, engine="openpyxl")
1833+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1834+
with ensure_clean() as path:
1835+
df.to_excel(Path(path), engine="openpyxl")
1836+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1837+
with ensure_clean() as path:
1838+
df.to_excel(path, engine="openpyxl", startrow=1, startcol=1, header=False)
1839+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1840+
with ensure_clean() as path:
1841+
df.to_excel(path, engine="openpyxl", sheet_name="sheet", index=False)
1842+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1843+
with ensure_clean() as path:
1844+
df.to_excel(path, engine="openpyxl", header=["x", "y"])
1845+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
1846+
with ensure_clean() as path:
1847+
df.to_excel(path, engine="openpyxl", columns=["col1"])
1848+
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
18421849

18431850

18441851
def test_join() -> None:

0 commit comments

Comments
 (0)