Skip to content

Commit

Permalink
CI: test on 3.12 (#839)
Browse files Browse the repository at this point in the history
* CI: test on 3.12

* simpler solution

* fix nightly
  • Loading branch information
twoertwein committed Dec 26, 2023
1 parent 70605ea commit 0a567b4
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 28 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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ ci:
autofix_prs: false
repos:
- repo: https://github.com/python/black
rev: 23.12.0
rev: 23.12.1
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
rev: v0.1.9
hooks:
- id: ruff
args: [
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
11 changes: 9 additions & 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 @@ -62,7 +62,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 Expand Up @@ -199,6 +198,14 @@ useLibraryCodeForTypes = false
[tool.codespell]
ignore-words-list = "indext, mose, sav, ser"

[tool.pytest.ini_options]
filterwarnings = [
# treat warnings as errors
"error",
# until there is a new dateutil release: github.com/dateutil/dateutil/pull/1285
"ignore:datetime.datetime.utc:DeprecationWarning",
]

# Next line needed to avoid poetry complaint
[tool.setuptools_scm]

4 changes: 2 additions & 2 deletions scripts/test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def pyright_src():
subprocess.run(cmd, check=True)


def pytest(flags: tuple[str, ...] = ("-Werror",)):
cmd = ["pytest", "--cache-clear", *flags]
def pytest():
cmd = ["pytest", "--cache-clear"]
subprocess.run(cmd, check=True)


Expand Down
44 changes: 28 additions & 16 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,31 +1699,43 @@ class ReadCsvKwargs(TypedDict):
pd.DataFrame,
)
parse_dates_2 = {"combined_date": ["Year", "Month", "Day"]}
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_2), pd.DataFrame),
pd.DataFrame,
)
with pytest_warns_bounded(
FutureWarning, "Support for nested sequences", lower="2.1.99"
):
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_2), pd.DataFrame),
pd.DataFrame,
)
parse_dates_3 = {"combined_date": [1, 2, 3]}
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_3), pd.DataFrame),
pd.DataFrame,
)
with pytest_warns_bounded(
FutureWarning, "Support for nested sequences", lower="2.1.99"
):
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_3), pd.DataFrame),
pd.DataFrame,
)
# MyPy calls this Dict[str, object] by default which necessitates the explicit annotation (Pyright does not)
parse_dates_4: dict[str, list[str | int]] = {"combined_date": [1, "Month", 3]}
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_4), pd.DataFrame),
pd.DataFrame,
)
with pytest_warns_bounded(
FutureWarning, "Support for nested sequences", lower="2.1.99"
):
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_4), pd.DataFrame),
pd.DataFrame,
)
parse_dates_5 = [0]
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_5), pd.DataFrame),
pd.DataFrame,
)
parse_dates_6 = [[1, 2, 3]]
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_6), pd.DataFrame),
pd.DataFrame,
)
with pytest_warns_bounded(
FutureWarning, "Support for nested sequences", lower="2.1.99"
):
check(
assert_type(pd.read_csv(path, parse_dates=parse_dates_6), pd.DataFrame),
pd.DataFrame,
)


def test_groupby_series_methods() -> None:
Expand Down
15 changes: 12 additions & 3 deletions tests/test_utility.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import platform

import pandas as pd
import pytest
from typing_extensions import assert_type

from tests import check
from tests import (
check,
pytest_warns_bounded,
)


def test_show_version():
with pytest.warns(UserWarning, match="Setuptools is replacing distutils"):
with pytest_warns_bounded(
UserWarning,
match="Setuptools is replacing distutils",
upper="3.11.99",
version_str=platform.python_version(),
):
check(assert_type(pd.show_versions(True), None), type(None))
check(assert_type(pd.show_versions(False), None), type(None))

Expand Down

0 comments on commit 0a567b4

Please sign in to comment.