Skip to content

Commit

Permalink
CI: test on 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
twoertwein committed Dec 23, 2023
1 parent c0ca527 commit b598270
Show file tree
Hide file tree
Showing 7 changed files with 479 additions and 369 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
Expand Down
13 changes: 11 additions & 2 deletions pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from datetime import (
timedelta,
tzinfo as _tzinfo,
)
import sys
from time import struct_time
from typing import (
ClassVar,
Expand Down Expand Up @@ -99,8 +100,16 @@ class Timestamp(datetime):
def tz(self) -> _tzinfo | None: ...
@property
def fold(self) -> int: ...
@classmethod
def fromtimestamp(cls, t: float, tz: _tzinfo | str | None = ...) -> Self: ...

if sys.version_info < (3, 12):
@classmethod
def fromtimestamp(cls, t: float, tz: _tzinfo | str | None = ...) -> Self: ...
else:
@classmethod
def fromtimestamp( # pyright: ignore[reportIncompatibleMethodOverride]
cls, t: float, tz: _tzinfo | str | None = ...
) -> Self: ...

@classmethod
def utcfromtimestamp(cls, ts: float) -> Self: ...
@classmethod
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ types-pytz = ">= 2022.1.1"
numpy = { version = ">=1.26.0", python = "<3.13" }

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

Expand Down
14 changes: 10 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@
)
import os
import platform
import sys
from typing import (
TYPE_CHECKING,
Final,
TypeVar,
)

import pandas as pd
from pandas.util.version import Version
import pytest

from pandas._typing import T
if sys.version_info < (3, 12):
import pandas as pd
else:
with pytest.warns(DeprecationWarning, match="datetime.datetime.utcfromtimestamp"):
import pandas as pd
from pandas.util.version import Version

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


def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left") -> T:
def check(actual: _T, klass: type, dtype: type | None = None, attr: str = "left") -> _T:
if not isinstance(actual, klass):
raise RuntimeError(f"Expected type '{klass}' but got '{type(actual)}'")
if dtype is None:
Expand Down
43 changes: 25 additions & 18 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io
import itertools
from pathlib import Path
import platform
import string
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -1821,24 +1822,30 @@ def test_frame_getitem_isin() -> None:
def test_to_excel() -> None:
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})

with ensure_clean() as path:
df.to_excel(path, engine="openpyxl")
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(Path(path), engine="openpyxl")
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl", startrow=1, startcol=1, header=False)
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl", sheet_name="sheet", index=False)
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl", header=["x", "y"])
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl", columns=["col1"])
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with pytest_warns_bounded(
DeprecationWarning,
match="datetime.datetime.utcnow",
lower="3.11.99",
version_str=platform.python_version(),
):
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl")
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(Path(path), engine="openpyxl")
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl", startrow=1, startcol=1, header=False)
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl", sheet_name="sheet", index=False)
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl", header=["x", "y"])
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)
with ensure_clean() as path:
df.to_excel(path, engine="openpyxl", columns=["col1"])
check(assert_type(pd.read_excel(path), pd.DataFrame), pd.DataFrame)


def test_join() -> None:
Expand Down
Loading

0 comments on commit b598270

Please sign in to comment.