Skip to content

CI: test on 3.12 #839

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 4 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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(),
):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this pattern is appearing all over the place, and hopefully we can one day remove it, it might be better to just create a special item in tests/__init__.py that returns

 pytest_warns_bounded(
        DeprecationWarning,
        match="datetime.datetime.utcnow",
        lower="3.11.99",
        version_str=platform.python_version(),
    )

Then we know there is one place that is catching the same warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a nicer solution :) pytest_warns_bounded is used in only one place now, so I don't think creating a new function for it would make sense anymore.

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